@gjsify/cli 0.3.12 → 0.3.14

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,123 @@
1
+ // One-release deprecation shim: maps the legacy `esbuild?: BuildOptions`
2
+ // field on `.gjsifyrc.js` / `package.json#gjsify` into the equivalent
3
+ // `bundler?: RolldownOptions` shape. Logs a single warning per build.
4
+ //
5
+ // Drop in 0.5.0.
6
+ let warnedOnce = false;
7
+ export function normalizeBundlerOptions(configData) {
8
+ const fromBundler = (configData.bundler ?? {});
9
+ if (!configData.esbuild)
10
+ return fromBundler;
11
+ if (!warnedOnce) {
12
+ warnedOnce = true;
13
+ // eslint-disable-next-line no-console
14
+ console.warn("[gjsify] DEPRECATION: the 'esbuild' config key is deprecated and will be removed in 0.5.0. " +
15
+ "Rename it to 'bundler' (typed as RolldownOptions). See the migration notes in the gjsify CHANGELOG.");
16
+ }
17
+ const fromEsbuild = legacyEsbuildToRolldown(configData.esbuild);
18
+ // Plain user-config merge — we deliberately do NOT call
19
+ // `mergeBundlerOptions` here, because that function strips `input` and
20
+ // `external` from its overrides arg (it assumes the *orchestrator* is
21
+ // the override source and the user the base). Here both inputs are
22
+ // user-provided config and `input` must survive the merge.
23
+ const out = { ...fromEsbuild, ...fromBundler };
24
+ if (fromEsbuild.output || fromBundler.output) {
25
+ out.output = { ...(fromEsbuild.output ?? {}), ...(fromBundler.output ?? {}) };
26
+ }
27
+ if (fromEsbuild.transform || fromBundler.transform) {
28
+ out.transform = { ...(fromEsbuild.transform ?? {}), ...(fromBundler.transform ?? {}) };
29
+ if (fromEsbuild.transform?.define || fromBundler.transform?.define) {
30
+ out.transform.define = {
31
+ ...(fromEsbuild.transform?.define ?? {}),
32
+ ...(fromBundler.transform?.define ?? {}),
33
+ };
34
+ }
35
+ }
36
+ if (fromEsbuild.resolve || fromBundler.resolve) {
37
+ out.resolve = { ...(fromEsbuild.resolve ?? {}), ...(fromBundler.resolve ?? {}) };
38
+ }
39
+ return out;
40
+ }
41
+ /** Map the supported subset of esbuild BuildOptions into RolldownOptions. */
42
+ function legacyEsbuildToRolldown(esb) {
43
+ const out = {};
44
+ const output = {};
45
+ const transform = {};
46
+ const resolve = {};
47
+ if (esb.outfile !== undefined)
48
+ output.file = esb.outfile;
49
+ if (esb.outdir !== undefined)
50
+ output.dir = esb.outdir;
51
+ if (esb.format !== undefined)
52
+ output.format = esb.format;
53
+ if (esb.minify !== undefined)
54
+ output.minify = esb.minify;
55
+ if (esb.sourcemap !== undefined) {
56
+ // esbuild has 'external' / 'both' which Rolldown doesn't — coerce to boolean.
57
+ output.sourcemap =
58
+ esb.sourcemap === 'inline'
59
+ ? 'inline'
60
+ : Boolean(esb.sourcemap);
61
+ }
62
+ if (esb.banner?.js !== undefined)
63
+ output.banner = esb.banner.js;
64
+ if (esb.target !== undefined) {
65
+ transform.target = Array.isArray(esb.target) ? esb.target.join(',') : esb.target;
66
+ }
67
+ if (esb.define !== undefined)
68
+ transform.define = esb.define;
69
+ if (esb.mainFields !== undefined)
70
+ resolve.mainFields = esb.mainFields;
71
+ if (esb.conditions !== undefined)
72
+ resolve.conditionNames = esb.conditions;
73
+ if (esb.external !== undefined)
74
+ out.external = esb.external;
75
+ if (esb.platform !== undefined)
76
+ out.platform = esb.platform;
77
+ if (Object.keys(output).length > 0)
78
+ out.output = output;
79
+ if (Object.keys(transform).length > 0)
80
+ out.transform = transform;
81
+ if (Object.keys(resolve).length > 0)
82
+ out.resolve = resolve;
83
+ // Discarded silently:
84
+ // esb.inject — esbuild's array-of-side-effect-files; surfaced at the
85
+ // CLI layer instead, via input expansion.
86
+ // esb.loader — Rolldown infers module types from extensions natively.
87
+ return out;
88
+ }
89
+ /**
90
+ * Shallow merge with deep-merge of `output`, `transform`, and `resolve`. The
91
+ * second argument wins on conflicts, matching `merge(target, ...sources)`
92
+ * semantics from `@gjsify/rolldown-plugin-gjsify/utils/merge`.
93
+ *
94
+ * `base` is typically the Rolldown-generic shape returned by the orchestrator;
95
+ * `overrides` is the user's `BundlerOptions` from `.gjsifyrc.js` plus CLI
96
+ * flag merges. Single-output assumption matches `BundlerOptions['output']`.
97
+ *
98
+ * The orchestrator-side `input` is authoritative — it's the post-glob-expansion
99
+ * value. Overriding it with the user's raw glob string would re-introduce
100
+ * unresolved glob patterns into the final Rolldown call. Same for `external`,
101
+ * which the orchestrator concatenates with platform defaults already.
102
+ */
103
+ export function mergeBundlerOptions(base, overrides) {
104
+ // Strip fields the orchestrator owns authoritatively — the user has
105
+ // already had their say via the orchestrator's `userExternal` / input
106
+ // expansion; merging the raw values back on top would clobber the
107
+ // post-processing.
108
+ const { input: _ignoredInput, external: _ignoredExternal, ...overridesRest } = overrides;
109
+ const out = { ...base, ...overridesRest };
110
+ if (base.output || overrides.output) {
111
+ out.output = { ...(base.output ?? {}), ...(overrides.output ?? {}) };
112
+ }
113
+ if (base.transform || overrides.transform) {
114
+ out.transform = { ...(base.transform ?? {}), ...(overrides.transform ?? {}) };
115
+ if (base.transform?.define || overrides.transform?.define) {
116
+ out.transform.define = { ...(base.transform?.define ?? {}), ...(overrides.transform?.define ?? {}) };
117
+ }
118
+ }
119
+ if (base.resolve || overrides.resolve) {
120
+ out.resolve = { ...(base.resolve ?? {}), ...(overrides.resolve ?? {}) };
121
+ }
122
+ return out;
123
+ }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@gjsify/cli",
3
- "version": "0.3.12",
3
+ "version": "0.3.14",
4
4
  "description": "CLI for Gjsify",
5
5
  "type": "module",
6
6
  "main": "lib/index.js",
@@ -23,19 +23,19 @@
23
23
  "cli"
24
24
  ],
25
25
  "dependencies": {
26
- "@gjsify/create-app": "^0.3.12",
27
- "@gjsify/esbuild-plugin-gjsify": "^0.3.12",
28
- "@gjsify/node-polyfills": "^0.3.12",
29
- "@gjsify/npm-registry": "^0.3.12",
30
- "@gjsify/resolve-npm": "^0.3.12",
31
- "@gjsify/semver": "^0.3.12",
32
- "@gjsify/tar": "^0.3.12",
33
- "@gjsify/web-polyfills": "^0.3.12",
34
- "@yarnpkg/esbuild-plugin-pnp": "^3.0.0-rc.15",
26
+ "@gjsify/create-app": "^0.3.14",
27
+ "@gjsify/node-polyfills": "^0.3.14",
28
+ "@gjsify/npm-registry": "^0.3.14",
29
+ "@gjsify/resolve-npm": "^0.3.14",
30
+ "@gjsify/rolldown-plugin-gjsify": "^0.3.14",
31
+ "@gjsify/rolldown-plugin-pnp": "^0.3.14",
32
+ "@gjsify/semver": "^0.3.14",
33
+ "@gjsify/tar": "^0.3.14",
34
+ "@gjsify/web-polyfills": "^0.3.14",
35
35
  "cosmiconfig": "^9.0.1",
36
- "esbuild": "^0.28.0",
37
36
  "get-tsconfig": "^4.14.0",
38
37
  "pkg-types": "^2.3.1",
38
+ "rolldown": "^1.0.0-rc.18",
39
39
  "yargs": "^18.0.0"
40
40
  },
41
41
  "devDependencies": {