Skip to content

Function: parseModuleId() ​

  • Exported from: rolldown/utils
  • Type: (id: string) => { attributes: Record<string, string>; rawId: string; }

Splits a module id into the raw id and the import attributes it was built from.

Only an id in the exact format that Rolldown uses is split. Any other id, e.g. virtual?attributes=foo, is returned as the raw id with no attributes. See Module ids for the format.

Parameters ​

id ​

string

Returns ​

{ attributes: Record<string, string>; rawId: string; }

attributes ​

  • Type: Record<string, string>

rawId ​

  • Type: string

Example ​

js
parseModuleId('/src/a.json?attributes=%7B%22type%22%3A%22json%22%7D');
// → { rawId: '/src/a.json', attributes: { type: 'json' } }
parseModuleId('/src/a.js?raw');
// → { rawId: '/src/a.js?raw', attributes: {} }

Was this page helpful?