Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -142,6 +142,7 @@ This plugin takes an [import map](https://github.com/WICG/import-maps) as option
| path | `cwd/eik.json` | `string` | `false` | Path to eik.json file. |
| urls | `[]` | `array` | `false` | Array of import map URLs to fetch from. |
| maps | `[]` | `array` | `false` | Array of import map as objects. |
| base | `` | `string` | `false` | Base URL to be applied when parsing the import map. |

## Note on the rollup external option

Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,6 @@
"dependencies": {
"@eik/common": "3.0.1",
"undici": "5.12.0",
"rollup-plugin-import-map": "3.0.0"
"rollup-plugin-import-map": "4.0.0-next.1"
}
}
7 changes: 5 additions & 2 deletions src/plugin.js
Original file line number Diff line number Diff line change
Expand Up @@ -29,10 +29,11 @@ const fetchImportMaps = async (urls = []) => {
}
};

export default function esmImportToUrl({
export default function eikPlugin({
path = process.cwd(),
maps = [],
urls = [],
base = '',
} = {}) {
const pMaps = Array.isArray(maps) ? maps : [maps];
const pUrls = Array.isArray(urls) ? urls : [urls];
Expand All @@ -48,7 +49,9 @@ export default function esmImportToUrl({
// Fetch import maps from the server
const fetched = await fetchImportMaps([...config.map, ...pUrls]);

plugin = importMapPlugin([...fetched, ...pMaps]);
const pBase = (base === '') ? config.server : base;

plugin = importMapPlugin(pBase, [...fetched, ...pMaps]);
await plugin.buildStart(options);
},

Expand Down
1 change: 1 addition & 0 deletions test/plugin.js
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@ tap.test('plugin() - import map fetched from a URL', async (t) => {
},
}],
urls: [`${address}/one`, `${address}/two`],
base: 'https://cdn.eik.dev',
})],
};

Expand Down