@xplane/devtools 0.15.1 → 0.16.0
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.
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
//#region src/bundler/index.d.ts
|
|
2
|
+
/**
|
|
3
|
+
* Minimal bundler plugin interface compatible with Rollup, Rolldown, and Vite.
|
|
4
|
+
*/
|
|
5
|
+
interface BundlerPlugin {
|
|
6
|
+
name: string;
|
|
7
|
+
resolveId?(id: string): string | undefined | null;
|
|
8
|
+
load?(id: string): string | undefined | null;
|
|
9
|
+
}
|
|
10
|
+
/**
|
|
11
|
+
* Rollup/Rolldown/Vite plugin that replaces `@xplane/core` and `constructs` imports
|
|
12
|
+
* with references to the VM sandbox globals.
|
|
13
|
+
*
|
|
14
|
+
* This produces a lightweight bundle that still uses `import { Composition, Resource }
|
|
15
|
+
* from '@xplane/core'` in source but resolves them to the sandbox-injected globals
|
|
16
|
+
* at build time — no copy of `@xplane/core` is included in the output.
|
|
17
|
+
*
|
|
18
|
+
* @example
|
|
19
|
+
* ```ts
|
|
20
|
+
* import { defineConfig } from 'tsdown';
|
|
21
|
+
* import { vmGlobals } from '@xplane/devtools/bundler';
|
|
22
|
+
*
|
|
23
|
+
* export default defineConfig({
|
|
24
|
+
* entry: ['src/index.ts'],
|
|
25
|
+
* format: 'cjs',
|
|
26
|
+
* plugins: [vmGlobals()],
|
|
27
|
+
* });
|
|
28
|
+
* ```
|
|
29
|
+
*/
|
|
30
|
+
declare function vmGlobals(): BundlerPlugin;
|
|
31
|
+
//#endregion
|
|
32
|
+
export { BundlerPlugin, vmGlobals };
|
|
33
|
+
//# sourceMappingURL=index.d.mts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.mts","names":[],"sources":["../../src/bundler/index.ts"],"mappings":";;AAGA;;UAAiB,aAAA;EACf,IAAA;EACA,SAAA,EAAW,EAAA;EACX,IAAA,EAAM,EAAA;AAAA;;;;AAAU;AAuBlB;;;;AAA0C;;;;;;;;;;;;iBAA1B,SAAA,CAAA,GAAa,aAAa"}
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
//#region src/bundler/index.ts
|
|
2
|
+
/**
|
|
3
|
+
* Rollup/Rolldown/Vite plugin that replaces `@xplane/core` and `constructs` imports
|
|
4
|
+
* with references to the VM sandbox globals.
|
|
5
|
+
*
|
|
6
|
+
* This produces a lightweight bundle that still uses `import { Composition, Resource }
|
|
7
|
+
* from '@xplane/core'` in source but resolves them to the sandbox-injected globals
|
|
8
|
+
* at build time — no copy of `@xplane/core` is included in the output.
|
|
9
|
+
*
|
|
10
|
+
* @example
|
|
11
|
+
* ```ts
|
|
12
|
+
* import { defineConfig } from 'tsdown';
|
|
13
|
+
* import { vmGlobals } from '@xplane/devtools/bundler';
|
|
14
|
+
*
|
|
15
|
+
* export default defineConfig({
|
|
16
|
+
* entry: ['src/index.ts'],
|
|
17
|
+
* format: 'cjs',
|
|
18
|
+
* plugins: [vmGlobals()],
|
|
19
|
+
* });
|
|
20
|
+
* ```
|
|
21
|
+
*/
|
|
22
|
+
function vmGlobals() {
|
|
23
|
+
return {
|
|
24
|
+
name: "xplane-vm-globals",
|
|
25
|
+
resolveId(id) {
|
|
26
|
+
if (id === "@xplane/core" || id === "constructs") return `\0${id}`;
|
|
27
|
+
},
|
|
28
|
+
load(id) {
|
|
29
|
+
if (id === "\0@xplane/core") return "export const Composition = globalThis.Composition; export const Resource = globalThis.Resource; export const Construct = globalThis.Construct;";
|
|
30
|
+
if (id === "\0constructs") return "export const Construct = globalThis.Construct;";
|
|
31
|
+
}
|
|
32
|
+
};
|
|
33
|
+
}
|
|
34
|
+
//#endregion
|
|
35
|
+
export { vmGlobals };
|
|
36
|
+
|
|
37
|
+
//# sourceMappingURL=index.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.mjs","names":[],"sources":["../../src/bundler/index.ts"],"sourcesContent":["/**\n * Minimal bundler plugin interface compatible with Rollup, Rolldown, and Vite.\n */\nexport interface BundlerPlugin {\n name: string;\n resolveId?(id: string): string | undefined | null;\n load?(id: string): string | undefined | null;\n}\n\n/**\n * Rollup/Rolldown/Vite plugin that replaces `@xplane/core` and `constructs` imports\n * with references to the VM sandbox globals.\n *\n * This produces a lightweight bundle that still uses `import { Composition, Resource }\n * from '@xplane/core'` in source but resolves them to the sandbox-injected globals\n * at build time — no copy of `@xplane/core` is included in the output.\n *\n * @example\n * ```ts\n * import { defineConfig } from 'tsdown';\n * import { vmGlobals } from '@xplane/devtools/bundler';\n *\n * export default defineConfig({\n * entry: ['src/index.ts'],\n * format: 'cjs',\n * plugins: [vmGlobals()],\n * });\n * ```\n */\nexport function vmGlobals(): BundlerPlugin {\n return {\n name: 'xplane-vm-globals',\n resolveId(id) {\n if (id === '@xplane/core' || id === 'constructs') return `\\0${id}`;\n },\n load(id) {\n if (id === '\\0@xplane/core')\n return 'export const Composition = globalThis.Composition; export const Resource = globalThis.Resource; export const Construct = globalThis.Construct;';\n if (id === '\\0constructs') return 'export const Construct = globalThis.Construct;';\n },\n };\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;AA6BA,SAAgB,YAA2B;CACzC,OAAO;EACL,MAAM;EACN,UAAU,IAAI;GACZ,IAAI,OAAO,kBAAkB,OAAO,cAAc,OAAO,KAAK;EAChE;EACA,KAAK,IAAI;GACP,IAAI,OAAO,kBACT,OAAO;GACT,IAAI,OAAO,gBAAgB,OAAO;EACpC;CACF;AACF"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@xplane/devtools",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.16.0",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"description": "Developer tools and testing utilities for @xplane/core compositions",
|
|
6
6
|
"license": "Apache-2.0",
|
|
@@ -16,6 +16,10 @@
|
|
|
16
16
|
"./assertions": {
|
|
17
17
|
"import": "./dist/assertions/index.mjs",
|
|
18
18
|
"types": "./dist/assertions/index.d.mts"
|
|
19
|
+
},
|
|
20
|
+
"./bundler": {
|
|
21
|
+
"import": "./dist/bundler/index.mjs",
|
|
22
|
+
"types": "./dist/bundler/index.d.mts"
|
|
19
23
|
}
|
|
20
24
|
},
|
|
21
25
|
"files": [
|
|
@@ -26,11 +30,11 @@
|
|
|
26
30
|
"tsdown": "^0.22.0",
|
|
27
31
|
"typescript": "6.0.3",
|
|
28
32
|
"vitest": "4.1.6",
|
|
29
|
-
"@xplane/core": "0.
|
|
33
|
+
"@xplane/core": "0.16.0"
|
|
30
34
|
},
|
|
31
35
|
"peerDependencies": {
|
|
32
36
|
"constructs": "^10.0.0",
|
|
33
|
-
"@xplane/core": "0.
|
|
37
|
+
"@xplane/core": "0.16.0"
|
|
34
38
|
},
|
|
35
39
|
"scripts": {
|
|
36
40
|
"build": "tsdown",
|