@gjsify/rolldown-plugin-gjsify 0.4.5 → 0.4.10

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/lib/app/gjs.js +19 -2
  2. package/package.json +7 -7
package/lib/app/gjs.js CHANGED
@@ -242,11 +242,21 @@ function wrapInputWithSideEffects(input, sideEffects) {
242
242
  const sideEffectImports = sideEffects
243
243
  .map((p) => `import ${JSON.stringify(p)};`)
244
244
  .join('\n');
245
+ // Resolved real-path targets from `userEntries` get their
246
+ // moduleSideEffects forced to 'no-treeshake' so the user-entry's
247
+ // top-level body (`run({...})`, side-effect calls) survives tree-shake
248
+ // even when its package.json restricts sideEffects to register files.
249
+ const resolvedTargets = new Set();
245
250
  const plugin = {
246
251
  name: 'gjsify-virtual-entry',
247
252
  async resolveId(source, importer) {
248
253
  if (source.startsWith(PREFIX))
249
254
  return source;
255
+ // Force-mark the resolved user-entry target as having
256
+ // top-level side effects.
257
+ if (resolvedTargets.has(source)) {
258
+ return { id: source, moduleSideEffects: 'no-treeshake' };
259
+ }
250
260
  return null;
251
261
  },
252
262
  async load(id) {
@@ -261,9 +271,16 @@ function wrapInputWithSideEffects(input, sideEffects) {
261
271
  // specifier and emits it as an external import.
262
272
  const resolved = await this.resolve(realPath, undefined, { skipSelf: true });
263
273
  const target = resolved?.id ?? realPath;
274
+ resolvedTargets.add(target);
275
+ // The bare `export * from <target>` re-exports named bindings
276
+ // but does NOT execute the source module's top-level body. A
277
+ // companion side-effect-only `import <target>` plus our
278
+ // resolveId-side `moduleSideEffects: 'no-treeshake'` mark
279
+ // forces the body to run — `run({...})` calls in test entries,
280
+ // top-level await, etc.
264
281
  return {
265
- code: `${sideEffectImports}\nexport * from ${JSON.stringify(target)};\n`,
266
- moduleSideEffects: true,
282
+ code: `${sideEffectImports}\nimport ${JSON.stringify(target)};\nexport * from ${JSON.stringify(target)};\n`,
283
+ moduleSideEffects: 'no-treeshake',
267
284
  };
268
285
  },
269
286
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@gjsify/rolldown-plugin-gjsify",
3
- "version": "0.4.5",
3
+ "version": "0.4.10",
4
4
  "description": "Rolldown / Rollup / Vite plugin orchestrator for GJS, Node, and Browser targets",
5
5
  "type": "module",
6
6
  "main": "lib/index.js",
@@ -45,11 +45,11 @@
45
45
  ],
46
46
  "license": "MIT",
47
47
  "dependencies": {
48
- "@gjsify/console": "^0.4.5",
49
- "@gjsify/resolve-npm": "^0.4.5",
50
- "@gjsify/rolldown-plugin-deepkit": "^0.4.5",
51
- "@gjsify/rolldown-plugin-pnp": "^0.4.5",
52
- "@gjsify/vite-plugin-blueprint": "^0.4.5",
48
+ "@gjsify/console": "^0.4.10",
49
+ "@gjsify/resolve-npm": "^0.4.10",
50
+ "@gjsify/rolldown-plugin-deepkit": "^0.4.10",
51
+ "@gjsify/rolldown-plugin-pnp": "^0.4.10",
52
+ "@gjsify/vite-plugin-blueprint": "^0.4.10",
53
53
  "@rollup/pluginutils": "^5.3.0",
54
54
  "acorn": "^8.16.0",
55
55
  "acorn-walk": "^8.3.5",
@@ -57,7 +57,7 @@
57
57
  "lightningcss": "^1.32.0"
58
58
  },
59
59
  "peerDependencies": {
60
- "@gjsify/lightningcss-native": "^0.4.5",
60
+ "@gjsify/lightningcss-native": "^0.4.10",
61
61
  "rolldown": "^1.0.0-rc.18"
62
62
  },
63
63
  "peerDependenciesMeta": {