@gjsify/rolldown-plugin-gjsify 0.64.60-next.368 → 0.64.60

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.
package/lib/app/gjs.js CHANGED
@@ -1,10 +1,6 @@
1
1
  // `--app gjs` Rolldown configuration factory: returns a partial
2
2
  // `RolldownOptions` template plus the plugin array the caller composes with
3
3
  // their user options. Library mode is `setupLib`.
4
- import { fileURLToPath } from 'node:url';
5
- import { dirname, resolve } from 'node:path';
6
- import { existsSync } from 'node:fs';
7
- import { createRequire } from 'node:module';
8
4
  import { aliasPlugin } from '../plugins/alias.js';
9
5
  import { externalsPlugin } from '../plugins/externals.js';
10
6
  import { napiNodeAddonPlugin } from '../plugins/napi-node-addon.js';
@@ -27,33 +23,7 @@ import { implicitGlobalAssignPlugin } from '../plugins/implicit-global-assign.js
27
23
  import { workerUrlPlugin } from '../plugins/worker-url.js';
28
24
  import { shebangPlugin, resolveShebangLine, inputShebangStripPlugin } from '../plugins/shebang.js';
29
25
  import { wrapInputWithSideEffects } from '../utils/entry-wrapper.js';
30
- const _shimDir = dirname(fileURLToPath(import.meta.url));
31
- /**
32
- * Resolve one of this package's bundled shims to an absolute path.
33
- *
34
- * `createRequire` is used only for its `exports`-map-aware RESOLVER; nothing is
35
- * loaded through it (this source is ESM — see AGENTS.md "no bare `require`").
36
- */
37
- function resolveShim(shimName) {
38
- // Normal Node consumption: `_shimDir` = `<pkg>/lib/app/`.
39
- const relative = resolve(_shimDir, `../shims/${shimName}.js`);
40
- if (existsSync(relative))
41
- return relative;
42
- // Fallback for the bundled-orchestrator case (GJS-CLI self-host loop):
43
- // `_shimDir` collapses to the bundle's own directory and the relative lookup
44
- // misses. Every shim MUST therefore be a `./shims/<name>` subpath export in
45
- // package.json.
46
- try {
47
- return createRequire(import.meta.url).resolve(`@gjsify/rolldown-plugin-gjsify/shims/${shimName}`);
48
- }
49
- catch (cause) {
50
- // Throw rather than return the unverified `relative`: a non-existent
51
- // path in the alias map resurfaces much later as an unrelated "could not
52
- // resolve" naming a path nobody wrote.
53
- throw new Error(`@gjsify/rolldown-plugin-gjsify: cannot locate the "${shimName}" shim. ` +
54
- `Tried ${relative} and the "./shims/${shimName}" subpath export.`, { cause });
55
- }
56
- }
26
+ import { resolveShim } from '../utils/resolve-shim.js';
57
27
  export const setupForGjs = async (input) => {
58
28
  const userExternal = input.userExternal ?? [];
59
29
  // Externals policy in TWO forms, because `@gjsify/rolldown-native` (the
@@ -4,5 +4,5 @@ export { setupForNode, enableGjsRegistersForNode, isGjsSourceBuild } from './nod
4
4
  export type { NodeBuildConfig, NodeFactoryInput } from './node.js';
5
5
  export { setupForBrowser } from './browser.js';
6
6
  export type { BrowserBuildConfig, BrowserFactoryInput } from './browser.js';
7
- export { setupForNativescript } from './nativescript.js';
7
+ export { setupForNativescript, resolveNativescriptGlobalsShim } from './nativescript.js';
8
8
  export type { NativescriptBuildConfig, NativescriptFactoryInput } from './nativescript.js';
package/lib/app/index.js CHANGED
@@ -1,4 +1,4 @@
1
1
  export { setupForGjs, isRegisterSubpath, isGjsifyShim, createGjsExternalsPredicate } from './gjs.js';
2
2
  export { setupForNode, enableGjsRegistersForNode, isGjsSourceBuild } from './node.js';
3
3
  export { setupForBrowser } from './browser.js';
4
- export { setupForNativescript } from './nativescript.js';
4
+ export { setupForNativescript, resolveNativescriptGlobalsShim } from './nativescript.js';
@@ -17,4 +17,11 @@ export interface NativescriptFactoryInput {
17
17
  pluginOptions: PluginOptions;
18
18
  }
19
19
  export declare const NATIVESCRIPT_CORE_EXTERNAL_PLUGIN = "gjsify-nativescript-core-external";
20
+ /**
21
+ * The module that installs the Node globals NativeScript's runtime lacks
22
+ * (`setImmediate` / `clearImmediate`). Both `--app nativescript` paths evaluate it first:
23
+ * a free-identifier scan of the app would miss a global only a dependency in
24
+ * `node_modules` uses, and there is no runtime to fall back on once it is missing.
25
+ */
26
+ export declare function resolveNativescriptGlobalsShim(): string;
20
27
  export declare const setupForNativescript: (input: NativescriptFactoryInput) => Promise<NativescriptBuildConfig>;
@@ -41,6 +41,8 @@ import { aliasPlugin } from '../plugins/alias.js';
41
41
  import blueprintPlugin from '@gjsify/vite-plugin-blueprint';
42
42
  import { deepkitPlugin } from '@gjsify/rolldown-plugin-deepkit';
43
43
  import { ALIASES_NODE_FOR_NATIVESCRIPT, GI_RENDERERS, getDerivedAliasesSync } from '@gjsify/resolve-npm';
44
+ import { wrapInputWithSideEffects } from '../utils/entry-wrapper.js';
45
+ import { resolveShim } from '../utils/resolve-shim.js';
44
46
  import { globToEntryPoints } from '../utils/entry-points.js';
45
47
  import { gjsImportsEmptyPlugin } from '../plugins/gjs-imports-empty.js';
46
48
  import { giRendererPlugin } from '../plugins/gi-renderer.js';
@@ -69,6 +71,15 @@ const nativescriptCoreExternalPlugin = () => ({
69
71
  name: NATIVESCRIPT_CORE_EXTERNAL_PLUGIN,
70
72
  resolveId: (id) => (NATIVESCRIPT_CORE.test(id) ? { id, external: true } : null),
71
73
  });
74
+ /**
75
+ * The module that installs the Node globals NativeScript's runtime lacks
76
+ * (`setImmediate` / `clearImmediate`). Both `--app nativescript` paths evaluate it first:
77
+ * a free-identifier scan of the app would miss a global only a dependency in
78
+ * `node_modules` uses, and there is no runtime to fall back on once it is missing.
79
+ */
80
+ export function resolveNativescriptGlobalsShim() {
81
+ return resolveShim('nativescript-globals');
82
+ }
72
83
  export const setupForNativescript = async (input) => {
73
84
  const userExternal = input.userExternal ?? [];
74
85
  // Only the caller's EXACT names go to the engine; the core subpath set is a hook (see
@@ -127,8 +138,11 @@ export const setupForNativescript = async (input) => {
127
138
  ...input.pluginOptions.aliases,
128
139
  ...input.userAliases,
129
140
  };
141
+ const virtualEntries = wrapInputWithSideEffects(entryPoints, [resolveNativescriptGlobalsShim()], {
142
+ preserveDefaultExport: input.pluginOptions.preserveDefaultExport === true,
143
+ });
130
144
  const options = {
131
- input: entryPoints,
145
+ input: virtualEntries.input,
132
146
  // NS's V8 is a "browser-shaped" runtime from Rolldown's perspective:
133
147
  // no Node-builtin auto-externals, no globalThis-shaped node-only
134
148
  // semantics. `browser` platform is the closest match — the actual
@@ -179,6 +193,7 @@ export const setupForNativescript = async (input) => {
179
193
  // claim it — `aliasPlugin` and the platform-suffix chain both match on specifier
180
194
  // shape and would otherwise pull a second core instance into the bundle.
181
195
  nativescriptCoreExternalPlugin(),
196
+ ...(virtualEntries.plugin ? [virtualEntries.plugin] : []),
182
197
  // ADR 0034 stage 9 — the `gi://` arm, ahead of the empty redirect so it
183
198
  // claims the specifier first, exactly as `gjsGiNodePlugin` does on the node
184
199
  // target. `emptyGirs` follows it: with the arm on, `@girs/<ns>-<ver>` must
@@ -0,0 +1 @@
1
+ import '@gjsify/timers/register';
@@ -0,0 +1,8 @@
1
+ // Node globals a NativeScript runtime lacks, installed before any app or dependency
2
+ // module evaluates. Entered by both `--app nativescript` paths (Rolldown entry wrapper,
3
+ // Vite bundler-context prepend). Each import is a no-op where the host has the global.
4
+ //
5
+ // The specifier is followed at USER-build time, like `console-gjs`'s, so this package
6
+ // only needs `@gjsify/timers` installed next to it, not built before it.
7
+ // @ts-ignore: resolved by the bundler at user-build time, not by tsc here.
8
+ import '@gjsify/timers/register';
@@ -0,0 +1,7 @@
1
+ /**
2
+ * Resolve one of this package's bundled shims to an absolute path.
3
+ *
4
+ * `createRequire` is used only for its `exports`-map-aware RESOLVER; nothing is
5
+ * loaded through it (this source is ESM — see AGENTS.md "no bare `require`").
6
+ */
7
+ export declare function resolveShim(shimName: string): string;
@@ -0,0 +1,31 @@
1
+ import { createRequire } from 'node:module';
2
+ import { existsSync } from 'node:fs';
3
+ import { dirname, resolve } from 'node:path';
4
+ import { fileURLToPath } from 'node:url';
5
+ const _shimDir = dirname(fileURLToPath(import.meta.url));
6
+ /**
7
+ * Resolve one of this package's bundled shims to an absolute path.
8
+ *
9
+ * `createRequire` is used only for its `exports`-map-aware RESOLVER; nothing is
10
+ * loaded through it (this source is ESM — see AGENTS.md "no bare `require`").
11
+ */
12
+ export function resolveShim(shimName) {
13
+ // Normal Node consumption: `_shimDir` = `<pkg>/lib/utils/`.
14
+ const relative = resolve(_shimDir, `../shims/${shimName}.js`);
15
+ if (existsSync(relative))
16
+ return relative;
17
+ // Fallback for the bundled-orchestrator case (GJS-CLI self-host loop):
18
+ // `_shimDir` collapses to the bundle's own directory and the relative lookup
19
+ // misses. Every shim MUST therefore be a `./shims/<name>` subpath export in
20
+ // package.json.
21
+ try {
22
+ return createRequire(import.meta.url).resolve(`@gjsify/rolldown-plugin-gjsify/shims/${shimName}`);
23
+ }
24
+ catch (cause) {
25
+ // Throw rather than return the unverified `relative`: a non-existent
26
+ // path in the alias map resurfaces much later as an unrelated "could not
27
+ // resolve" naming a path nobody wrote.
28
+ throw new Error(`@gjsify/rolldown-plugin-gjsify: cannot locate the "${shimName}" shim. ` +
29
+ `Tried ${relative} and the "./shims/${shimName}" subpath export.`, { cause });
30
+ }
31
+ }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@gjsify/rolldown-plugin-gjsify",
3
- "version": "0.64.60-next.368",
3
+ "version": "0.64.60",
4
4
  "description": "Rolldown / Rollup / Vite plugin orchestrator for GJS, Node, and Browser targets",
5
5
  "type": "module",
6
6
  "main": "lib/index.js",
@@ -33,6 +33,9 @@
33
33
  },
34
34
  "./shims/unicorn-magic": {
35
35
  "default": "./lib/shims/unicorn-magic.js"
36
+ },
37
+ "./shims/nativescript-globals": {
38
+ "default": "./lib/shims/nativescript-globals.js"
36
39
  }
37
40
  },
38
41
  "files": [
@@ -67,13 +70,14 @@
67
70
  ],
68
71
  "license": "MIT",
69
72
  "dependencies": {
70
- "@gjsify/console": "0.64.60-next.368",
71
- "@gjsify/resolve-npm": "0.64.60-next.368",
72
- "@gjsify/rolldown-plugin-deepkit": "0.64.60-next.368",
73
- "@gjsify/rolldown-plugin-pnp": "0.64.60-next.368",
74
- "@gjsify/utils": "0.64.60-next.368",
75
- "@gjsify/vite-plugin-blueprint": "0.64.60-next.368",
76
- "@gjsify/vite-plugin-gettext": "0.64.60-next.368",
73
+ "@gjsify/console": "0.64.60",
74
+ "@gjsify/resolve-npm": "0.64.60",
75
+ "@gjsify/rolldown-plugin-deepkit": "0.64.60",
76
+ "@gjsify/rolldown-plugin-pnp": "0.64.60",
77
+ "@gjsify/timers": "0.64.60",
78
+ "@gjsify/utils": "0.64.60",
79
+ "@gjsify/vite-plugin-blueprint": "0.64.60",
80
+ "@gjsify/vite-plugin-gettext": "0.64.60",
77
81
  "@rollup/pluginutils": "^5.4.0",
78
82
  "acorn": "^8.17.0",
79
83
  "acorn-typescript": "^1.4.13",
@@ -83,7 +87,7 @@
83
87
  "sass": "^1.101.0"
84
88
  },
85
89
  "peerDependencies": {
86
- "@gjsify/lightningcss-native": "0.64.60-next.368",
90
+ "@gjsify/lightningcss-native": "0.64.60",
87
91
  "rolldown": "^1.1.4"
88
92
  },
89
93
  "peerDependenciesMeta": {
@@ -95,8 +99,8 @@
95
99
  }
96
100
  },
97
101
  "devDependencies": {
98
- "@gjsify/cli": "0.64.60-next.368",
99
- "@gjsify/unit": "0.64.60-next.368",
102
+ "@gjsify/cli": "0.64.60",
103
+ "@gjsify/unit": "0.64.60",
100
104
  "@types/node": "^25.9.2",
101
105
  "rolldown": "^1.1.4",
102
106
  "typescript": "^6.0.3"
@@ -108,6 +112,5 @@
108
112
  "darwin": "supported",
109
113
  "win32": "supported"
110
114
  }
111
- },
112
- "gitHead": "bc5216978780476bb76edc9c1a920f5d837590a0"
115
+ }
113
116
  }