You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
* chore(deps): upgrade vite to v8.0.16
* chore(deps): install @eik/common
* test: update snapshots
* refactor(plugin): inline import-map logic, drop @eik/rollup-plugin
* chore(deps): uninstall @eik/rollup-plugin
* feat(plugin)!: convert external require calls to ESM facades for Rolldown
Adds handling for require() calls of mapped specifiers under Vite 8 /
Rolldown. Rolldown no longer auto-converts external require() to ESM
import (see
vite.dev/guide/migration#require-calls-for-externalized-modules), so the
plugin now routes each require() to a virtual ESM facade that imports
the URL, letting the bundler's CJS interop wrap it at the call site.
BREAKING CHANGE: targets Vite 8+ as the supported runtime. Output may
include one additional virtual chunk per require()-mapped specifier.
* test(plugin): cover require() of mapped specifier
test(fixtures): add cjs fixture for require() tests
* test(plugin): cover mixed import + require for the same specifier
test(fixtures): add mixed import + require fixture
* test(plugin): cover require() of unmapped dependency
* docs(readme): document Vite 8 / Rolldown require handling
Copy file name to clipboardExpand all lines: README.md
+15-4Lines changed: 15 additions & 4 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -2,7 +2,7 @@
2
2
3
3
[Vite](https://vite.dev/) plugin for [build-time import mapping with Eik](https://eik.dev/docs/guides/vite).
4
4
5
-
This is a small wrapper around the [Rollup plugin](https://github.com/eik-lib/rollup-plugin) to make it slightly more ergonomic to use in Vite.
5
+
Resolves bare import specifiers in your client bundle to URLs hosted on an Eik server, so shared dependencies (React, lit, etc.) load from one place across apps instead of being bundled into each one.
6
6
7
7
## Installation
8
8
@@ -24,7 +24,7 @@ export default defineConfig({
24
24
// Turn off the asset hashes. Stable file names
25
25
// make it easier to use the Eik node client:
26
26
// https://github.com/eik-lib/node-client
27
-
//Publishinig a new version on Eik gives a
27
+
//Publishing a new version on Eik gives a
28
28
// unique URL, no hash needed.
29
29
assetFileNames:"[name].[ext]",
30
30
entryFileNames:"[name].js",
@@ -37,5 +37,16 @@ export default defineConfig({
37
37
38
38
## Options
39
39
40
-
The options you can give to `eik()` are the same as for the Rollup plugin.
41
-
Refer to [the Rollup plugin documentation](https://github.com/eik-lib/rollup-plugin?tab=readme-ov-file#options) to see what you can do.
|`path`|`string`|`process.cwd()`| Path to `eik.json`. |
43
+
|`urls`|`string[]`|`[]`| URLs to import maps hosted on an Eik server. Takes precedence over `eik.json`. |
44
+
|`maps`|`ImportMap \| ImportMap[]`|`[]`| Inline import maps. Takes precedence over `urls` and `eik.json`. |
45
+
46
+
An `ImportMap` is `{ imports: Record<string, string> }`.
47
+
48
+
## Vite 8 / Rolldown
49
+
50
+
Static `import` statements of mapped specifiers are rewritten to external URL imports. `require()` calls of mapped specifiers are routed through a virtual ESM facade so the bundler's CJS interop wraps them at the call site.
51
+
52
+
Without the facade, Rolldown would leave a literal `require("<url>")` in the output bundle, which throws in the browser. See the [Vite 8 migration note](https://vite.dev/guide/migration#require-calls-for-externalized-modules) for background.
0 commit comments