@rmc-toolkit/vite 0.2.0 → 0.2.4

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (2) hide show
  1. package/README.md +71 -0
  2. package/package.json +8 -3
package/README.md ADDED
@@ -0,0 +1,71 @@
1
+ # @rmc-toolkit/vite
2
+
3
+ Vite/Rollup adapter for [Runtime Module Composition](https://runtime-module-composition.dev): injects the generated import map into a host's HTML before any module script runs, externalizes import-map-owned specifiers so Vite doesn't bundle or rewrite them, and provides `defineSliceBuild()` for a slice's own build config.
4
+
5
+ ## Install
6
+
7
+ ```bash
8
+ npm install @rmc-toolkit/vite @rmc-toolkit/core vite
9
+ ```
10
+
11
+ ## Quick example
12
+
13
+ **Host** — wire the plugin into `vite.config.ts`:
14
+
15
+ ```ts
16
+ import { defineConfig } from "vite";
17
+ import { runtimeComposition } from "@rmc-toolkit/vite";
18
+ import { manifest } from "./runtime-composition.manifest";
19
+
20
+ export default defineConfig({
21
+ plugins: [
22
+ ...runtimeComposition({
23
+ manifest,
24
+ environment: "development",
25
+ }),
26
+ ],
27
+ });
28
+ ```
29
+
30
+ `runtimeComposition()` returns two plugins: one that injects the generated import map into `index.html`, and one that tells Vite not to bundle or rewrite specifiers the import map owns.
31
+
32
+ **Slice** — build as an ESM library that externalizes anything the import map owns:
33
+
34
+ ```ts
35
+ import { defineConfig } from "vite";
36
+ import { defineSliceBuild, createRollupExternal } from "@rmc-toolkit/vite";
37
+ import { manifest } from "./runtime-composition.manifest";
38
+
39
+ export default defineConfig(({ mode }) => {
40
+ const sliceBuild = defineSliceBuild({ mode, devPort: 5174, sliceName: "search" });
41
+
42
+ return mode === "development"
43
+ ? sliceBuild
44
+ : {
45
+ ...sliceBuild,
46
+ build: {
47
+ ...sliceBuild.build,
48
+ rollupOptions: { external: createRollupExternal(manifest) },
49
+ },
50
+ };
51
+ });
52
+ ```
53
+
54
+ `sliceName` determines where the production build lands (`dist/{sliceName}/index.mjs`), matching the path convention `resolveRoute()`/`createImportMap()` already assume — a slice's build output requires no separate assembly step to match its production URL.
55
+
56
+ ## What's in here
57
+
58
+ - `runtimeComposition` — the combined host-side plugin pair (import-map injection + externalization).
59
+ - `includeRuntimeImportMap`, `externalizeRuntimeComposition` — the two plugins individually, if you need only one.
60
+ - `createRollupExternal` — a Rollup `external` function, for a slice's production build.
61
+ - `defineSliceBuild` — mode-aware Vite config for a slice (dev-server port, the library-build `process.env.NODE_ENV` fix, entry auto-detection).
62
+ - `includeHostedImportMap`, `buildLocalImportMapScript` — for serving the import map as a standalone hosted script rather than inlined into HTML (e.g. a production static-asset host), with local-dev override support.
63
+
64
+ Full signatures and behavior for every export: [API Reference](https://runtime-module-composition.dev/api-reference/#vite-adapter-rmc-toolkitvite).
65
+
66
+ ## Documentation
67
+
68
+ - [Getting Started](https://runtime-module-composition.dev/getting-started/) — install and wire up a host + slice end to end
69
+ - [API Reference](https://runtime-module-composition.dev/api-reference/#vite-adapter-rmc-toolkitvite)
70
+ - [Technical Implementation](https://runtime-module-composition.dev/technical-implementation/) — the architecture and failure modes behind the pattern
71
+ - [Multi-Framework Demo](https://runtime-module-composition.dev/demo/) — a full, runnable reference implementation
package/package.json CHANGED
@@ -1,7 +1,12 @@
1
1
  {
2
2
  "name": "@rmc-toolkit/vite",
3
- "version": "0.2.0",
3
+ "version": "0.2.4",
4
4
  "type": "module",
5
+ "repository": {
6
+ "type": "git",
7
+ "url": "https://github.com/runtime-module-composition/rmc-toolkit",
8
+ "directory": "packages/vite"
9
+ },
5
10
  "main": "./dist/index.js",
6
11
  "types": "./dist/index.d.ts",
7
12
  "exports": {
@@ -17,11 +22,11 @@
17
22
  "access": "public"
18
23
  },
19
24
  "peerDependencies": {
20
- "@rmc-toolkit/core": "0.2.0",
25
+ "@rmc-toolkit/core": "0.2.4",
21
26
  "vite": ">=5"
22
27
  },
23
28
  "dependencies": {
24
- "@rmc-toolkit/core": "0.2.0",
29
+ "@rmc-toolkit/core": "0.2.4",
25
30
  "vite-plugin-js-importmap-script": "^1.0.0"
26
31
  },
27
32
  "scripts": {