rollipop 0.1.0-alpha.13 → 0.1.0-alpha.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.
package/CHANGELOG.md CHANGED
@@ -1,5 +1,13 @@
1
1
  # rollipop
2
2
 
3
+ ## 0.1.0-alpha.14
4
+
5
+ ### Patch Changes
6
+
7
+ - dca60fd: add `devMode.useFileSystemBundle` for raw bundle debugging
8
+ - 2c1a088: enable `externalHelpers`
9
+ - 7438e0b: bump version up dependencies
10
+
3
11
  ## 0.1.0-alpha.13
4
12
 
5
13
  ### Patch Changes
package/dist/commands.cjs CHANGED
@@ -155,7 +155,7 @@ const DEBUG_KEY = "rollipop";
155
155
  const SHARED_DATA_PATH = ".rollipop";
156
156
 
157
157
  //#endregion
158
- //#region src/common/debug.ts
158
+ //#region src/common/env.ts
159
159
  const TRUTHY_VALUES = [
160
160
  "yes",
161
161
  "on",
@@ -185,6 +185,13 @@ function isDebugEnabled() {
185
185
  if (debugKeys == null) debugKeys = parseDebugKeys();
186
186
  return debugKeys[DEBUG_KEY] ?? false;
187
187
  }
188
+ function getBundleStoreMode() {
189
+ switch (process.env.BUNDLE_STORE) {
190
+ case "fs":
191
+ case "memory": return process.env.BUNDLE_STORE;
192
+ default: return "memory";
193
+ }
194
+ }
188
195
 
189
196
  //#endregion
190
197
  //#region src/common/logger.ts
@@ -1564,7 +1571,7 @@ function replaceSourceMappingURL(code, sourceMappingURL) {
1564
1571
 
1565
1572
  //#endregion
1566
1573
  //#region src/server/bundle.ts
1567
- var InMemoryBundle = class {
1574
+ var InMemoryBundleStore = class {
1568
1575
  lazySourceMapConsumer = null;
1569
1576
  constructor(_code, _sourceMap, sourceMappingURL) {
1570
1577
  this._code = _code;
@@ -1583,6 +1590,42 @@ var InMemoryBundle = class {
1583
1590
  return this.lazySourceMapConsumer;
1584
1591
  }
1585
1592
  };
1593
+ var FileSystemBundleStore = class {
1594
+ bundleFilePath;
1595
+ holder;
1596
+ constructor(projectRoot, id, code) {
1597
+ const sharedDataPath = getSharedDataPath(projectRoot);
1598
+ const bundlesPath = node_path.default.join(sharedDataPath, "bundles");
1599
+ const bundleFilePath = node_path.default.join(bundlesPath, `${id}.bundle`);
1600
+ if (!node_fs.default.existsSync(bundlesPath)) node_fs.default.mkdirSync(bundlesPath, { recursive: true });
1601
+ node_fs.default.writeFileSync(bundleFilePath, code, { encoding: "utf-8" });
1602
+ const stats = node_fs.default.statSync(bundleFilePath);
1603
+ this.bundleFilePath = bundleFilePath;
1604
+ this.holder = {
1605
+ code,
1606
+ mtimeMs: stats.mtimeMs
1607
+ };
1608
+ logger$1.info(`File system bundle created at ${bundleFilePath}`);
1609
+ }
1610
+ update() {
1611
+ this.holder = {
1612
+ code: node_fs.default.readFileSync(this.bundleFilePath, { encoding: "utf-8" }),
1613
+ mtimeMs: node_fs.default.statSync(this.bundleFilePath).mtimeMs
1614
+ };
1615
+ }
1616
+ get code() {
1617
+ if (this.isStale()) {
1618
+ logger$1.info("File system bundle is stale, updating...");
1619
+ this.update();
1620
+ } else logger$1.trace("File system bundle is up to date");
1621
+ return this.holder.code;
1622
+ }
1623
+ get sourceMap() {}
1624
+ get sourceMapConsumer() {}
1625
+ isStale() {
1626
+ return this.holder.mtimeMs !== node_fs.default.statSync(this.bundleFilePath).mtimeMs;
1627
+ }
1628
+ };
1586
1629
 
1587
1630
  //#endregion
1588
1631
  //#region src/server/bundler-pool.ts
@@ -1590,7 +1633,7 @@ var BundlerDevEngine = class extends node_events.default {
1590
1633
  initializeHandle;
1591
1634
  isHmrEnabled;
1592
1635
  _id;
1593
- bundle = null;
1636
+ bundleStore = null;
1594
1637
  buildFailedError = null;
1595
1638
  _devEngine = null;
1596
1639
  _state = "idle";
@@ -1652,8 +1695,7 @@ var BundlerDevEngine = class extends node_events.default {
1652
1695
  this.emit("buildFailed", normalizedError);
1653
1696
  } else {
1654
1697
  const output = errorOrResult.output[0];
1655
- const sourceMap = output.map?.toString();
1656
- this.bundle = new InMemoryBundle(output.code, sourceMap, this.sourceMappingURL);
1698
+ this.updateBundleStore(output);
1657
1699
  this.buildFailedError = null;
1658
1700
  logger.debug("Build completed", {
1659
1701
  bundlerId: this.id,
@@ -1668,6 +1710,9 @@ var BundlerDevEngine = class extends node_events.default {
1668
1710
  this._state = "ready";
1669
1711
  this.initializeHandle.resolve();
1670
1712
  }
1713
+ updateBundleStore(output) {
1714
+ this.bundleStore = getBundleStoreMode() === "fs" ? new FileSystemBundleStore(this.config.root, this.id, output.code) : new InMemoryBundleStore(output.code, output.map?.toString(), this.sourceMappingURL);
1715
+ }
1671
1716
  async getBundle() {
1672
1717
  await this.ensureInitialized;
1673
1718
  const state = await this.devEngine.getBundleState();
@@ -1676,9 +1721,9 @@ var BundlerDevEngine = class extends node_events.default {
1676
1721
  state
1677
1722
  });
1678
1723
  if (state.lastFullBuildFailed) throw new Error(this.buildFailedError?.message ?? "Build failed");
1679
- if (state.hasStaleOutput || this.bundle == null) await this.devEngine.ensureLatestBuildOutput();
1680
- (0, es_toolkit.invariant)(this.bundle, "Bundle is not available");
1681
- return this.bundle;
1724
+ if (state.hasStaleOutput || this.bundleStore == null) await this.devEngine.ensureLatestBuildOutput();
1725
+ (0, es_toolkit.invariant)(this.bundleStore, "Bundle is not available");
1726
+ return this.bundleStore;
1682
1727
  }
1683
1728
  };
1684
1729
  var BundlerPool = class BundlerPool {
@@ -1997,12 +2042,12 @@ const INTERNAL_CALLSITES_REGEX = new RegExp([
1997
2042
  "/node_modules/scheduler/.+\\.js$",
1998
2043
  "^\\[native code\\]$"
1999
2044
  ].map((pathPattern) => pathPattern.replaceAll("/", "[/\\\\]")).join("|"));
2000
- async function symbolicate(bundle, stack) {
2001
- const sourceMapConsumer = await bundle.sourceMapConsumer;
2002
- const symbolicatedStack = stack.filter((frame) => frame.file?.startsWith("http")).map((frame) => originalPositionFor(sourceMapConsumer, frame)).map((frame) => collapseFrame(frame));
2045
+ async function symbolicate(bundleStore, stack) {
2046
+ const sourceMapConsumer = await bundleStore.sourceMapConsumer;
2047
+ const symbolicatedStack = stack.filter((frame) => frame.file?.startsWith("http")).map((frame) => sourceMapConsumer ? originalPositionFor(sourceMapConsumer, frame) : frame).map((frame) => collapseFrame(frame));
2003
2048
  return {
2004
2049
  stack: symbolicatedStack,
2005
- codeFrame: getCodeFrame(sourceMapConsumer, symbolicatedStack, bundle)
2050
+ codeFrame: getCodeFrame(symbolicatedStack, bundleStore, sourceMapConsumer)
2006
2051
  };
2007
2052
  }
2008
2053
  function originalPositionFor(sourceMapConsumer, frame) {
@@ -2034,7 +2079,7 @@ function convertFrameKey(key) {
2034
2079
  else if (key === "name") return "methodName";
2035
2080
  return key;
2036
2081
  }
2037
- function getCodeFrame(sourceMapConsumer, frames, bundle) {
2082
+ function getCodeFrame(frames, bundleStore, sourceMapConsumer) {
2038
2083
  const frame = frames.find((frame) => {
2039
2084
  return frame.lineNumber != null && frame.column != null && !isCollapsed(frame);
2040
2085
  });
@@ -2042,7 +2087,7 @@ function getCodeFrame(sourceMapConsumer, frames, bundle) {
2042
2087
  try {
2043
2088
  const { lineNumber, column, file } = frame;
2044
2089
  const unresolved = file.startsWith("http");
2045
- const source = unresolved ? bundle.code : sourceMapConsumer.sourceContentFor(frame.file);
2090
+ const source = sourceMapConsumer == null || unresolved ? bundleStore.code : sourceMapConsumer.sourceContentFor(frame.file);
2046
2091
  const fileName = unresolved ? parseUrl(file).pathname ?? "unknown" : file;
2047
2092
  let content = "";
2048
2093
  if (source) content = (0, _babel_code_frame.codeFrameColumns)(source, { start: {
@@ -2702,6 +2747,10 @@ function generateAssetRegistryCode(assetRegistryPath, asset) {
2702
2747
  return `module.exports = require('${assetRegistryPath}').registerAsset(${JSON.stringify(asset)});`;
2703
2748
  }
2704
2749
 
2750
+ //#endregion
2751
+ //#region src/core/plugins/shared/filters.ts
2752
+ const ROLLDOWN_RUNTIME_EXCLUDE_FILTER = (0, _rollipop_rolldown_pluginutils.exclude)((0, _rollipop_rolldown_pluginutils.or)((0, _rollipop_rolldown_pluginutils.id)(/rolldown\/runtime/), (0, _rollipop_rolldown_pluginutils.id)(/@oxc-project\+runtime/)));
2753
+
2705
2754
  //#endregion
2706
2755
  //#region src/core/plugins/utils/transform-utils.ts
2707
2756
  const TRANSFORM_FLAGS_KEY = Symbol("transform-flags");
@@ -2765,8 +2814,7 @@ function getPersistCachePlugins(options) {
2765
2814
  afterTransform: null
2766
2815
  };
2767
2816
  const { sourceExtensions, context } = options;
2768
- const includePattern = new RegExp(`\\.(?:${sourceExtensions.join("|")})$`);
2769
- const filter = [(0, _rollipop_rolldown_pluginutils.exclude)((0, _rollipop_rolldown_pluginutils.or)((0, _rollipop_rolldown_pluginutils.id)(/rolldown\/runtime/), (0, _rollipop_rolldown_pluginutils.id)(/@oxc-project\+runtime/))), (0, _rollipop_rolldown_pluginutils.include)((0, _rollipop_rolldown_pluginutils.id)(includePattern))];
2817
+ const filter = [ROLLDOWN_RUNTIME_EXCLUDE_FILTER, (0, _rollipop_rolldown_pluginutils.include)((0, _rollipop_rolldown_pluginutils.id)(new RegExp(`\\.(?:${sourceExtensions.join("|")})$`)))];
2770
2818
  let cacheHits = 0;
2771
2819
  return {
2772
2820
  beforeTransform: {
@@ -2924,18 +2972,10 @@ function reactNativePlugin(config, options) {
2924
2972
  };
2925
2973
  const defaultRuntimeImplements = getDefaultRuntimeImplements();
2926
2974
  const hmrConfig = resolveHmrConfig(config);
2927
- const hmrClientPath = require.resolve(process.env.ROLLIPOP_HMR_CLIENT_PATH ?? DEFAULT_HMR_CLIENT_PATH, { paths: [config.root] });
2928
2975
  const replaceHMRClientPlugin = {
2929
2976
  name: "rollipop:react-native-replace-hmr-client",
2930
- resolveId: {
2931
- filter: [(0, _rollipop_rolldown_pluginutils.include)((0, _rollipop_rolldown_pluginutils.id)(/\/HMRClient\.js$/))],
2932
- async handler(id, importer) {
2933
- const resolvedId = await this.resolve(id, importer, { skipSelf: true });
2934
- if (resolvedId?.id === hmrClientPath) await this.load({ id: resolvedId.id });
2935
- }
2936
- },
2937
2977
  load: {
2938
- filter: [(0, _rollipop_rolldown_pluginutils.include)((0, _rollipop_rolldown_pluginutils.id)((0, _rollipop_rolldown_pluginutils.exactRegex)(hmrClientPath)))],
2978
+ filter: [(0, _rollipop_rolldown_pluginutils.include)((0, _rollipop_rolldown_pluginutils.id)((0, _rollipop_rolldown_pluginutils.exactRegex)(require.resolve(process.env.ROLLIPOP_HMR_CLIENT_PATH ?? DEFAULT_HMR_CLIENT_PATH, { paths: [config.root] }))))],
2939
2979
  handler(id) {
2940
2980
  this.debug(`Replacing HMR client: ${id}`);
2941
2981
  return hmrConfig?.clientImplement ?? defaultRuntimeImplements.clientImplement;
@@ -3209,6 +3249,16 @@ function merge$2(target, source, key) {
3209
3249
  function swcPlugin(options) {
3210
3250
  const { rules = [] } = options ?? {};
3211
3251
  const swcOptionsById = /* @__PURE__ */ new Map();
3252
+ const swcHelpersResolvePlugin = {
3253
+ name: "rollipop:swc-helpers-resolve",
3254
+ resolveId: {
3255
+ order: "pre",
3256
+ filter: [(0, _rollipop_rolldown_pluginutils.include)((0, _rollipop_rolldown_pluginutils.id)(/^@swc\/helpers/)), ROLLDOWN_RUNTIME_EXCLUDE_FILTER],
3257
+ handler(source, _importer, extraOptions) {
3258
+ return this.resolve(source, __dirname, extraOptions);
3259
+ }
3260
+ }
3261
+ };
3212
3262
  const swcRules = rules.map(({ filter, options }, index) => {
3213
3263
  return {
3214
3264
  name: `rollipop:swc-rule-${index}`,
@@ -3227,27 +3277,30 @@ function swcPlugin(options) {
3227
3277
  buildStart() {
3228
3278
  swcOptionsById.clear();
3229
3279
  },
3230
- transform: { handler(code, id) {
3231
- if (getFlag(this, id) & TransformFlag.SKIP_ALL) return;
3232
- const swcOptions = swcOptionsById.get(id) ?? [];
3233
- const baseOptions = getPreset();
3234
- const result = _swc_core.transformSync(code, {
3235
- filename: id,
3236
- configFile: false,
3237
- swcrc: false,
3238
- sourceMaps: true,
3239
- inputSourceMap: false,
3240
- ...mergeSwcOptions(baseOptions, ...swcOptions)
3241
- });
3242
- return {
3243
- code: result.code,
3244
- map: result.map
3245
- };
3246
- } }
3280
+ transform: {
3281
+ filter: [ROLLDOWN_RUNTIME_EXCLUDE_FILTER],
3282
+ handler(code, id) {
3283
+ if (getFlag(this, id) & TransformFlag.SKIP_ALL) return;
3284
+ const swcOptions = swcOptionsById.get(id) ?? [];
3285
+ const baseOptions = getPreset(id);
3286
+ const result = _swc_core.transformSync(code, {
3287
+ filename: id,
3288
+ configFile: false,
3289
+ swcrc: false,
3290
+ sourceMaps: true,
3291
+ inputSourceMap: false,
3292
+ ...mergeSwcOptions(baseOptions, ...swcOptions)
3293
+ });
3294
+ return {
3295
+ code: result.code,
3296
+ map: result.map
3297
+ };
3298
+ }
3299
+ }
3247
3300
  };
3248
- return [...swcRules, swcPlugin].map(cacheable);
3301
+ return [swcHelpersResolvePlugin, ...[...swcRules, swcPlugin].map(cacheable)];
3249
3302
  }
3250
- function getPreset() {
3303
+ function getPreset(id) {
3251
3304
  return {
3252
3305
  jsc: {
3253
3306
  target: "es5",
@@ -3261,9 +3314,10 @@ function getPreset() {
3261
3314
  assumptions: {
3262
3315
  setPublicClassFields: true,
3263
3316
  privateFieldsAsProperties: true
3264
- }
3317
+ },
3318
+ externalHelpers: true
3265
3319
  },
3266
- isModule: true
3320
+ isModule: id.endsWith(".cjs") ? "commonjs" : true
3267
3321
  };
3268
3322
  }
3269
3323
 
@@ -3388,10 +3442,13 @@ async function resolveRolldownOptions(context, config, buildOptions, devEngineOp
3388
3442
  tsconfig: config.tsconfig,
3389
3443
  resolve: mergedResolveOptions,
3390
3444
  transform: mergedTransformOptions,
3391
- optimization: rolldownOptimization,
3392
3445
  treeshake: rolldownTreeshake,
3393
3446
  external: rolldownExternal,
3394
3447
  shimMissingExports: rolldownShimMissingExports,
3448
+ optimization: {
3449
+ ...rolldownOptimization,
3450
+ inlineConst: false
3451
+ },
3395
3452
  experimental: { lazyBarrel: rolldownLazyBarrel },
3396
3453
  plugins: withTransformBoundary([
3397
3454
  preludePlugin({ modulePaths: preludePaths }),
package/dist/commands.js CHANGED
@@ -104,7 +104,7 @@ const DEBUG_KEY = "rollipop";
104
104
  const SHARED_DATA_PATH = ".rollipop";
105
105
 
106
106
  //#endregion
107
- //#region src/common/debug.ts
107
+ //#region src/common/env.ts
108
108
  const TRUTHY_VALUES = [
109
109
  "yes",
110
110
  "on",
@@ -134,6 +134,13 @@ function isDebugEnabled() {
134
134
  if (debugKeys == null) debugKeys = parseDebugKeys();
135
135
  return debugKeys[DEBUG_KEY] ?? false;
136
136
  }
137
+ function getBundleStoreMode() {
138
+ switch (process.env.BUNDLE_STORE) {
139
+ case "fs":
140
+ case "memory": return process.env.BUNDLE_STORE;
141
+ default: return "memory";
142
+ }
143
+ }
137
144
 
138
145
  //#endregion
139
146
  //#region src/common/logger.ts
@@ -1513,7 +1520,7 @@ function replaceSourceMappingURL(code, sourceMappingURL) {
1513
1520
 
1514
1521
  //#endregion
1515
1522
  //#region src/server/bundle.ts
1516
- var InMemoryBundle = class {
1523
+ var InMemoryBundleStore = class {
1517
1524
  lazySourceMapConsumer = null;
1518
1525
  constructor(_code, _sourceMap, sourceMappingURL) {
1519
1526
  this._code = _code;
@@ -1532,6 +1539,42 @@ var InMemoryBundle = class {
1532
1539
  return this.lazySourceMapConsumer;
1533
1540
  }
1534
1541
  };
1542
+ var FileSystemBundleStore = class {
1543
+ bundleFilePath;
1544
+ holder;
1545
+ constructor(projectRoot, id, code) {
1546
+ const sharedDataPath = getSharedDataPath(projectRoot);
1547
+ const bundlesPath = path.join(sharedDataPath, "bundles");
1548
+ const bundleFilePath = path.join(bundlesPath, `${id}.bundle`);
1549
+ if (!fs.existsSync(bundlesPath)) fs.mkdirSync(bundlesPath, { recursive: true });
1550
+ fs.writeFileSync(bundleFilePath, code, { encoding: "utf-8" });
1551
+ const stats = fs.statSync(bundleFilePath);
1552
+ this.bundleFilePath = bundleFilePath;
1553
+ this.holder = {
1554
+ code,
1555
+ mtimeMs: stats.mtimeMs
1556
+ };
1557
+ logger$1.info(`File system bundle created at ${bundleFilePath}`);
1558
+ }
1559
+ update() {
1560
+ this.holder = {
1561
+ code: fs.readFileSync(this.bundleFilePath, { encoding: "utf-8" }),
1562
+ mtimeMs: fs.statSync(this.bundleFilePath).mtimeMs
1563
+ };
1564
+ }
1565
+ get code() {
1566
+ if (this.isStale()) {
1567
+ logger$1.info("File system bundle is stale, updating...");
1568
+ this.update();
1569
+ } else logger$1.trace("File system bundle is up to date");
1570
+ return this.holder.code;
1571
+ }
1572
+ get sourceMap() {}
1573
+ get sourceMapConsumer() {}
1574
+ isStale() {
1575
+ return this.holder.mtimeMs !== fs.statSync(this.bundleFilePath).mtimeMs;
1576
+ }
1577
+ };
1535
1578
 
1536
1579
  //#endregion
1537
1580
  //#region src/server/bundler-pool.ts
@@ -1539,7 +1582,7 @@ var BundlerDevEngine = class extends EventEmitter {
1539
1582
  initializeHandle;
1540
1583
  isHmrEnabled;
1541
1584
  _id;
1542
- bundle = null;
1585
+ bundleStore = null;
1543
1586
  buildFailedError = null;
1544
1587
  _devEngine = null;
1545
1588
  _state = "idle";
@@ -1601,8 +1644,7 @@ var BundlerDevEngine = class extends EventEmitter {
1601
1644
  this.emit("buildFailed", normalizedError);
1602
1645
  } else {
1603
1646
  const output = errorOrResult.output[0];
1604
- const sourceMap = output.map?.toString();
1605
- this.bundle = new InMemoryBundle(output.code, sourceMap, this.sourceMappingURL);
1647
+ this.updateBundleStore(output);
1606
1648
  this.buildFailedError = null;
1607
1649
  logger.debug("Build completed", {
1608
1650
  bundlerId: this.id,
@@ -1617,6 +1659,9 @@ var BundlerDevEngine = class extends EventEmitter {
1617
1659
  this._state = "ready";
1618
1660
  this.initializeHandle.resolve();
1619
1661
  }
1662
+ updateBundleStore(output) {
1663
+ this.bundleStore = getBundleStoreMode() === "fs" ? new FileSystemBundleStore(this.config.root, this.id, output.code) : new InMemoryBundleStore(output.code, output.map?.toString(), this.sourceMappingURL);
1664
+ }
1620
1665
  async getBundle() {
1621
1666
  await this.ensureInitialized;
1622
1667
  const state = await this.devEngine.getBundleState();
@@ -1625,9 +1670,9 @@ var BundlerDevEngine = class extends EventEmitter {
1625
1670
  state
1626
1671
  });
1627
1672
  if (state.lastFullBuildFailed) throw new Error(this.buildFailedError?.message ?? "Build failed");
1628
- if (state.hasStaleOutput || this.bundle == null) await this.devEngine.ensureLatestBuildOutput();
1629
- invariant(this.bundle, "Bundle is not available");
1630
- return this.bundle;
1673
+ if (state.hasStaleOutput || this.bundleStore == null) await this.devEngine.ensureLatestBuildOutput();
1674
+ invariant(this.bundleStore, "Bundle is not available");
1675
+ return this.bundleStore;
1631
1676
  }
1632
1677
  };
1633
1678
  var BundlerPool = class BundlerPool {
@@ -1946,12 +1991,12 @@ const INTERNAL_CALLSITES_REGEX = new RegExp([
1946
1991
  "/node_modules/scheduler/.+\\.js$",
1947
1992
  "^\\[native code\\]$"
1948
1993
  ].map((pathPattern) => pathPattern.replaceAll("/", "[/\\\\]")).join("|"));
1949
- async function symbolicate(bundle, stack) {
1950
- const sourceMapConsumer = await bundle.sourceMapConsumer;
1951
- const symbolicatedStack = stack.filter((frame) => frame.file?.startsWith("http")).map((frame) => originalPositionFor(sourceMapConsumer, frame)).map((frame) => collapseFrame(frame));
1994
+ async function symbolicate(bundleStore, stack) {
1995
+ const sourceMapConsumer = await bundleStore.sourceMapConsumer;
1996
+ const symbolicatedStack = stack.filter((frame) => frame.file?.startsWith("http")).map((frame) => sourceMapConsumer ? originalPositionFor(sourceMapConsumer, frame) : frame).map((frame) => collapseFrame(frame));
1952
1997
  return {
1953
1998
  stack: symbolicatedStack,
1954
- codeFrame: getCodeFrame(sourceMapConsumer, symbolicatedStack, bundle)
1999
+ codeFrame: getCodeFrame(symbolicatedStack, bundleStore, sourceMapConsumer)
1955
2000
  };
1956
2001
  }
1957
2002
  function originalPositionFor(sourceMapConsumer, frame) {
@@ -1983,7 +2028,7 @@ function convertFrameKey(key) {
1983
2028
  else if (key === "name") return "methodName";
1984
2029
  return key;
1985
2030
  }
1986
- function getCodeFrame(sourceMapConsumer, frames, bundle) {
2031
+ function getCodeFrame(frames, bundleStore, sourceMapConsumer) {
1987
2032
  const frame = frames.find((frame) => {
1988
2033
  return frame.lineNumber != null && frame.column != null && !isCollapsed(frame);
1989
2034
  });
@@ -1991,7 +2036,7 @@ function getCodeFrame(sourceMapConsumer, frames, bundle) {
1991
2036
  try {
1992
2037
  const { lineNumber, column, file } = frame;
1993
2038
  const unresolved = file.startsWith("http");
1994
- const source = unresolved ? bundle.code : sourceMapConsumer.sourceContentFor(frame.file);
2039
+ const source = sourceMapConsumer == null || unresolved ? bundleStore.code : sourceMapConsumer.sourceContentFor(frame.file);
1995
2040
  const fileName = unresolved ? parseUrl(file).pathname ?? "unknown" : file;
1996
2041
  let content = "";
1997
2042
  if (source) content = codeFrameColumns(source, { start: {
@@ -2651,6 +2696,10 @@ function generateAssetRegistryCode(assetRegistryPath, asset) {
2651
2696
  return `module.exports = require('${assetRegistryPath}').registerAsset(${JSON.stringify(asset)});`;
2652
2697
  }
2653
2698
 
2699
+ //#endregion
2700
+ //#region src/core/plugins/shared/filters.ts
2701
+ const ROLLDOWN_RUNTIME_EXCLUDE_FILTER = exclude(or(id(/rolldown\/runtime/), id(/@oxc-project\+runtime/)));
2702
+
2654
2703
  //#endregion
2655
2704
  //#region src/core/plugins/utils/transform-utils.ts
2656
2705
  const TRANSFORM_FLAGS_KEY = Symbol("transform-flags");
@@ -2714,8 +2763,7 @@ function getPersistCachePlugins(options) {
2714
2763
  afterTransform: null
2715
2764
  };
2716
2765
  const { sourceExtensions, context } = options;
2717
- const includePattern = new RegExp(`\\.(?:${sourceExtensions.join("|")})$`);
2718
- const filter = [exclude(or(id(/rolldown\/runtime/), id(/@oxc-project\+runtime/))), include(id(includePattern))];
2766
+ const filter = [ROLLDOWN_RUNTIME_EXCLUDE_FILTER, include(id(new RegExp(`\\.(?:${sourceExtensions.join("|")})$`)))];
2719
2767
  let cacheHits = 0;
2720
2768
  return {
2721
2769
  beforeTransform: {
@@ -2873,18 +2921,10 @@ function reactNativePlugin(config, options) {
2873
2921
  };
2874
2922
  const defaultRuntimeImplements = getDefaultRuntimeImplements();
2875
2923
  const hmrConfig = resolveHmrConfig(config);
2876
- const hmrClientPath = __require.resolve(process.env.ROLLIPOP_HMR_CLIENT_PATH ?? DEFAULT_HMR_CLIENT_PATH, { paths: [config.root] });
2877
2924
  const replaceHMRClientPlugin = {
2878
2925
  name: "rollipop:react-native-replace-hmr-client",
2879
- resolveId: {
2880
- filter: [include(id(/\/HMRClient\.js$/))],
2881
- async handler(id, importer) {
2882
- const resolvedId = await this.resolve(id, importer, { skipSelf: true });
2883
- if (resolvedId?.id === hmrClientPath) await this.load({ id: resolvedId.id });
2884
- }
2885
- },
2886
2926
  load: {
2887
- filter: [include(id(exactRegex(hmrClientPath)))],
2927
+ filter: [include(id(exactRegex(__require.resolve(process.env.ROLLIPOP_HMR_CLIENT_PATH ?? DEFAULT_HMR_CLIENT_PATH, { paths: [config.root] }))))],
2888
2928
  handler(id) {
2889
2929
  this.debug(`Replacing HMR client: ${id}`);
2890
2930
  return hmrConfig?.clientImplement ?? defaultRuntimeImplements.clientImplement;
@@ -3158,6 +3198,16 @@ function merge$1(target, source, key) {
3158
3198
  function swcPlugin(options) {
3159
3199
  const { rules = [] } = options ?? {};
3160
3200
  const swcOptionsById = /* @__PURE__ */ new Map();
3201
+ const swcHelpersResolvePlugin = {
3202
+ name: "rollipop:swc-helpers-resolve",
3203
+ resolveId: {
3204
+ order: "pre",
3205
+ filter: [include(id(/^@swc\/helpers/)), ROLLDOWN_RUNTIME_EXCLUDE_FILTER],
3206
+ handler(source, _importer, extraOptions) {
3207
+ return this.resolve(source, import.meta.dirname, extraOptions);
3208
+ }
3209
+ }
3210
+ };
3161
3211
  const swcRules = rules.map(({ filter, options }, index) => {
3162
3212
  return {
3163
3213
  name: `rollipop:swc-rule-${index}`,
@@ -3176,27 +3226,30 @@ function swcPlugin(options) {
3176
3226
  buildStart() {
3177
3227
  swcOptionsById.clear();
3178
3228
  },
3179
- transform: { handler(code, id) {
3180
- if (getFlag(this, id) & TransformFlag.SKIP_ALL) return;
3181
- const swcOptions = swcOptionsById.get(id) ?? [];
3182
- const baseOptions = getPreset();
3183
- const result = swc.transformSync(code, {
3184
- filename: id,
3185
- configFile: false,
3186
- swcrc: false,
3187
- sourceMaps: true,
3188
- inputSourceMap: false,
3189
- ...mergeSwcOptions(baseOptions, ...swcOptions)
3190
- });
3191
- return {
3192
- code: result.code,
3193
- map: result.map
3194
- };
3195
- } }
3229
+ transform: {
3230
+ filter: [ROLLDOWN_RUNTIME_EXCLUDE_FILTER],
3231
+ handler(code, id) {
3232
+ if (getFlag(this, id) & TransformFlag.SKIP_ALL) return;
3233
+ const swcOptions = swcOptionsById.get(id) ?? [];
3234
+ const baseOptions = getPreset(id);
3235
+ const result = swc.transformSync(code, {
3236
+ filename: id,
3237
+ configFile: false,
3238
+ swcrc: false,
3239
+ sourceMaps: true,
3240
+ inputSourceMap: false,
3241
+ ...mergeSwcOptions(baseOptions, ...swcOptions)
3242
+ });
3243
+ return {
3244
+ code: result.code,
3245
+ map: result.map
3246
+ };
3247
+ }
3248
+ }
3196
3249
  };
3197
- return [...swcRules, swcPlugin].map(cacheable);
3250
+ return [swcHelpersResolvePlugin, ...[...swcRules, swcPlugin].map(cacheable)];
3198
3251
  }
3199
- function getPreset() {
3252
+ function getPreset(id) {
3200
3253
  return {
3201
3254
  jsc: {
3202
3255
  target: "es5",
@@ -3210,9 +3263,10 @@ function getPreset() {
3210
3263
  assumptions: {
3211
3264
  setPublicClassFields: true,
3212
3265
  privateFieldsAsProperties: true
3213
- }
3266
+ },
3267
+ externalHelpers: true
3214
3268
  },
3215
- isModule: true
3269
+ isModule: id.endsWith(".cjs") ? "commonjs" : true
3216
3270
  };
3217
3271
  }
3218
3272
 
@@ -3337,10 +3391,13 @@ async function resolveRolldownOptions(context, config, buildOptions, devEngineOp
3337
3391
  tsconfig: config.tsconfig,
3338
3392
  resolve: mergedResolveOptions,
3339
3393
  transform: mergedTransformOptions,
3340
- optimization: rolldownOptimization,
3341
3394
  treeshake: rolldownTreeshake,
3342
3395
  external: rolldownExternal,
3343
3396
  shimMissingExports: rolldownShimMissingExports,
3397
+ optimization: {
3398
+ ...rolldownOptimization,
3399
+ inlineConst: false
3400
+ },
3344
3401
  experimental: { lazyBarrel: rolldownLazyBarrel },
3345
3402
  plugins: withTransformBoundary([
3346
3403
  preludePlugin({ modulePaths: preludePaths }),
@@ -6,7 +6,7 @@ import f from "./Platform";
6
6
 
7
7
  //#region \0rolldown/runtime.js
8
8
  var __require = function(e) {
9
- return typeof require !== "undefined" ? require : typeof Proxy !== "undefined" ? new Proxy(e, { get: function(e, r) {
9
+ return typeof require !== "undefined" ? require : typeof Proxy !== "undefined" ? new Proxy(e, { get: function e(e, r) {
10
10
  return (typeof require !== "undefined" ? require : e)[r];
11
11
  } }) : e;
12
12
  }(function(e) {
@@ -354,7 +354,7 @@ var p = /* @__PURE__ */ function() {
354
354
  p.STARTUP_ERROR = "Expected HMRClient.setup() call at startup";
355
355
  p.MAX_PENDING_LOGS = 100;
356
356
  var g = new p();
357
- var hmr_client_default = Object.defineProperty(g, "default", { get: function() {
357
+ var hmr_client_default = Object.defineProperty(g, "default", { get: function e() {
358
358
  return g;
359
359
  } });
360
360
 
@@ -1,10 +1,10 @@
1
1
  //#region \0rolldown/runtime.js
2
- var __esmMin = function(e, r) {
2
+ var __esmMin = function e(e, r) {
3
3
  return function() {
4
4
  return e && (r = e(e = 0)), r;
5
5
  };
6
6
  };
7
- var __commonJSMin = function(e, r) {
7
+ var __commonJSMin = function e(e, r) {
8
8
  return function() {
9
9
  return r || e((r = { exports: {} }).exports, r), r.exports;
10
10
  };
@@ -431,7 +431,7 @@ var require_hmr_runtime = /* @__PURE__ */ __commonJSMin((() => {
431
431
  _class_call_check(this, ReactNativeDevRuntime1);
432
432
  var e;
433
433
  var t = new SocketHolder();
434
- var r = { send: function(e) {
434
+ var r = { send: function e(e) {
435
435
  return t.send(JSON.stringify(e));
436
436
  } };
437
437
  e = _call_super(this, ReactNativeDevRuntime1, [r]), e.moduleHotContexts = new Map(), e.moduleHotContextsToBeUpdated = new Map();
package/dist/index.d.ts CHANGED
@@ -2,7 +2,7 @@ import { ChalkInstance } from "chalk";
2
2
  import * as rolldown from "@rollipop/rolldown";
3
3
  import { RollupLogWithString } from "@rollipop/rolldown";
4
4
  import * as rolldownExperimental from "@rollipop/rolldown/experimental";
5
- import { DevEngine as DevEngine$1, DevOptions, DevWatchOptions, TransformOptions } from "@rollipop/rolldown/experimental";
5
+ import { DevEngine as DevEngine$1, DevOptions, DevWatchOptions } from "@rollipop/rolldown/experimental";
6
6
  import { TopLevelFilterExpression } from "@rollipop/rolldown-pluginutils";
7
7
  import { FastifyInstance as FastifyInstance$1 } from "fastify";
8
8
  import { Emitter } from "mitt";
@@ -12,6 +12,7 @@ import * as babel from "@babel/core";
12
12
  import * as swc from "@swc/core";
13
13
  import { Command } from "@commander-js/extra-typings";
14
14
  import * as fastifyMiddie from "@fastify/middie";
15
+ import { TransformOptions } from "@rollipop/rolldown/utils";
15
16
  import { Command as Command$1 } from "@react-native-community/cli-types";
16
17
 
17
18
  //#region src/types.d.ts
package/dist/index.js CHANGED
@@ -49,7 +49,7 @@ const DEBUG_KEY = "rollipop";
49
49
  const SHARED_DATA_PATH = ".rollipop";
50
50
 
51
51
  //#endregion
52
- //#region src/common/debug.ts
52
+ //#region src/common/env.ts
53
53
  const TRUTHY_VALUES = [
54
54
  "yes",
55
55
  "on",
@@ -79,6 +79,13 @@ function isDebugEnabled() {
79
79
  if (debugKeys == null) debugKeys = parseDebugKeys();
80
80
  return debugKeys[DEBUG_KEY] ?? false;
81
81
  }
82
+ function getBundleStoreMode() {
83
+ switch (process.env.BUNDLE_STORE) {
84
+ case "fs":
85
+ case "memory": return process.env.BUNDLE_STORE;
86
+ default: return "memory";
87
+ }
88
+ }
82
89
 
83
90
  //#endregion
84
91
  //#region src/common/transformer.ts
@@ -115,7 +122,7 @@ function generateSourceFromAst(ast, id) {
115
122
 
116
123
  //#endregion
117
124
  //#region src/constants.ts
118
- const ROLLIPOP_VERSION = "0.1.0-alpha.13";
125
+ const ROLLIPOP_VERSION = "0.1.0-alpha.14";
119
126
  const GLOBAL_IDENTIFIER = "__ROLLIPOP_GLOBAL__";
120
127
  /**
121
128
  * @see {@link https://github.com/facebook/metro/blob/0.81.x/docs/Configuration.md#resolvermainfields}
@@ -1297,7 +1304,7 @@ function replaceSourceMappingURL(code, sourceMappingURL) {
1297
1304
 
1298
1305
  //#endregion
1299
1306
  //#region src/server/bundle.ts
1300
- var InMemoryBundle = class {
1307
+ var InMemoryBundleStore = class {
1301
1308
  lazySourceMapConsumer = null;
1302
1309
  constructor(_code, _sourceMap, sourceMappingURL) {
1303
1310
  this._code = _code;
@@ -1316,6 +1323,42 @@ var InMemoryBundle = class {
1316
1323
  return this.lazySourceMapConsumer;
1317
1324
  }
1318
1325
  };
1326
+ var FileSystemBundleStore = class {
1327
+ bundleFilePath;
1328
+ holder;
1329
+ constructor(projectRoot, id, code) {
1330
+ const sharedDataPath = getSharedDataPath(projectRoot);
1331
+ const bundlesPath = path.join(sharedDataPath, "bundles");
1332
+ const bundleFilePath = path.join(bundlesPath, `${id}.bundle`);
1333
+ if (!fs.existsSync(bundlesPath)) fs.mkdirSync(bundlesPath, { recursive: true });
1334
+ fs.writeFileSync(bundleFilePath, code, { encoding: "utf-8" });
1335
+ const stats = fs.statSync(bundleFilePath);
1336
+ this.bundleFilePath = bundleFilePath;
1337
+ this.holder = {
1338
+ code,
1339
+ mtimeMs: stats.mtimeMs
1340
+ };
1341
+ logger$2.info(`File system bundle created at ${bundleFilePath}`);
1342
+ }
1343
+ update() {
1344
+ this.holder = {
1345
+ code: fs.readFileSync(this.bundleFilePath, { encoding: "utf-8" }),
1346
+ mtimeMs: fs.statSync(this.bundleFilePath).mtimeMs
1347
+ };
1348
+ }
1349
+ get code() {
1350
+ if (this.isStale()) {
1351
+ logger$2.info("File system bundle is stale, updating...");
1352
+ this.update();
1353
+ } else logger$2.trace("File system bundle is up to date");
1354
+ return this.holder.code;
1355
+ }
1356
+ get sourceMap() {}
1357
+ get sourceMapConsumer() {}
1358
+ isStale() {
1359
+ return this.holder.mtimeMs !== fs.statSync(this.bundleFilePath).mtimeMs;
1360
+ }
1361
+ };
1319
1362
 
1320
1363
  //#endregion
1321
1364
  //#region src/server/bundler-pool.ts
@@ -1323,7 +1366,7 @@ var BundlerDevEngine = class extends EventEmitter {
1323
1366
  initializeHandle;
1324
1367
  isHmrEnabled;
1325
1368
  _id;
1326
- bundle = null;
1369
+ bundleStore = null;
1327
1370
  buildFailedError = null;
1328
1371
  _devEngine = null;
1329
1372
  _state = "idle";
@@ -1385,8 +1428,7 @@ var BundlerDevEngine = class extends EventEmitter {
1385
1428
  this.emit("buildFailed", normalizedError);
1386
1429
  } else {
1387
1430
  const output = errorOrResult.output[0];
1388
- const sourceMap = output.map?.toString();
1389
- this.bundle = new InMemoryBundle(output.code, sourceMap, this.sourceMappingURL);
1431
+ this.updateBundleStore(output);
1390
1432
  this.buildFailedError = null;
1391
1433
  logger$1.debug("Build completed", {
1392
1434
  bundlerId: this.id,
@@ -1401,6 +1443,9 @@ var BundlerDevEngine = class extends EventEmitter {
1401
1443
  this._state = "ready";
1402
1444
  this.initializeHandle.resolve();
1403
1445
  }
1446
+ updateBundleStore(output) {
1447
+ this.bundleStore = getBundleStoreMode() === "fs" ? new FileSystemBundleStore(this.config.root, this.id, output.code) : new InMemoryBundleStore(output.code, output.map?.toString(), this.sourceMappingURL);
1448
+ }
1404
1449
  async getBundle() {
1405
1450
  await this.ensureInitialized;
1406
1451
  const state = await this.devEngine.getBundleState();
@@ -1409,9 +1454,9 @@ var BundlerDevEngine = class extends EventEmitter {
1409
1454
  state
1410
1455
  });
1411
1456
  if (state.lastFullBuildFailed) throw new Error(this.buildFailedError?.message ?? "Build failed");
1412
- if (state.hasStaleOutput || this.bundle == null) await this.devEngine.ensureLatestBuildOutput();
1413
- invariant(this.bundle, "Bundle is not available");
1414
- return this.bundle;
1457
+ if (state.hasStaleOutput || this.bundleStore == null) await this.devEngine.ensureLatestBuildOutput();
1458
+ invariant(this.bundleStore, "Bundle is not available");
1459
+ return this.bundleStore;
1415
1460
  }
1416
1461
  };
1417
1462
  var BundlerPool = class BundlerPool {
@@ -1730,12 +1775,12 @@ const INTERNAL_CALLSITES_REGEX = new RegExp([
1730
1775
  "/node_modules/scheduler/.+\\.js$",
1731
1776
  "^\\[native code\\]$"
1732
1777
  ].map((pathPattern) => pathPattern.replaceAll("/", "[/\\\\]")).join("|"));
1733
- async function symbolicate(bundle, stack) {
1734
- const sourceMapConsumer = await bundle.sourceMapConsumer;
1735
- const symbolicatedStack = stack.filter((frame) => frame.file?.startsWith("http")).map((frame) => originalPositionFor(sourceMapConsumer, frame)).map((frame) => collapseFrame(frame));
1778
+ async function symbolicate(bundleStore, stack) {
1779
+ const sourceMapConsumer = await bundleStore.sourceMapConsumer;
1780
+ const symbolicatedStack = stack.filter((frame) => frame.file?.startsWith("http")).map((frame) => sourceMapConsumer ? originalPositionFor(sourceMapConsumer, frame) : frame).map((frame) => collapseFrame(frame));
1736
1781
  return {
1737
1782
  stack: symbolicatedStack,
1738
- codeFrame: getCodeFrame(sourceMapConsumer, symbolicatedStack, bundle)
1783
+ codeFrame: getCodeFrame(symbolicatedStack, bundleStore, sourceMapConsumer)
1739
1784
  };
1740
1785
  }
1741
1786
  function originalPositionFor(sourceMapConsumer, frame) {
@@ -1767,7 +1812,7 @@ function convertFrameKey(key) {
1767
1812
  else if (key === "name") return "methodName";
1768
1813
  return key;
1769
1814
  }
1770
- function getCodeFrame(sourceMapConsumer, frames, bundle) {
1815
+ function getCodeFrame(frames, bundleStore, sourceMapConsumer) {
1771
1816
  const frame = frames.find((frame) => {
1772
1817
  return frame.lineNumber != null && frame.column != null && !isCollapsed(frame);
1773
1818
  });
@@ -1775,7 +1820,7 @@ function getCodeFrame(sourceMapConsumer, frames, bundle) {
1775
1820
  try {
1776
1821
  const { lineNumber, column, file } = frame;
1777
1822
  const unresolved = file.startsWith("http");
1778
- const source = unresolved ? bundle.code : sourceMapConsumer.sourceContentFor(frame.file);
1823
+ const source = sourceMapConsumer == null || unresolved ? bundleStore.code : sourceMapConsumer.sourceContentFor(frame.file);
1779
1824
  const fileName = unresolved ? parseUrl(file).pathname ?? "unknown" : file;
1780
1825
  let content = "";
1781
1826
  if (source) content = codeFrameColumns(source, { start: {
@@ -2445,6 +2490,10 @@ function generateAssetRegistryCode(assetRegistryPath, asset) {
2445
2490
  return `module.exports = require('${assetRegistryPath}').registerAsset(${JSON.stringify(asset)});`;
2446
2491
  }
2447
2492
 
2493
+ //#endregion
2494
+ //#region src/core/plugins/shared/filters.ts
2495
+ const ROLLDOWN_RUNTIME_EXCLUDE_FILTER = exclude(or(id(/rolldown\/runtime/), id(/@oxc-project\+runtime/)));
2496
+
2448
2497
  //#endregion
2449
2498
  //#region src/core/plugins/utils/transform-utils.ts
2450
2499
  const TRANSFORM_FLAGS_KEY = Symbol("transform-flags");
@@ -2508,8 +2557,7 @@ function getPersistCachePlugins(options) {
2508
2557
  afterTransform: null
2509
2558
  };
2510
2559
  const { sourceExtensions, context } = options;
2511
- const includePattern = new RegExp(`\\.(?:${sourceExtensions.join("|")})$`);
2512
- const filter = [exclude(or(id(/rolldown\/runtime/), id(/@oxc-project\+runtime/))), include(id(includePattern))];
2560
+ const filter = [ROLLDOWN_RUNTIME_EXCLUDE_FILTER, include(id(new RegExp(`\\.(?:${sourceExtensions.join("|")})$`)))];
2513
2561
  let cacheHits = 0;
2514
2562
  return {
2515
2563
  beforeTransform: {
@@ -2667,18 +2715,10 @@ function reactNativePlugin(config, options) {
2667
2715
  };
2668
2716
  const defaultRuntimeImplements = getDefaultRuntimeImplements();
2669
2717
  const hmrConfig = resolveHmrConfig(config);
2670
- const hmrClientPath = __require.resolve(process.env.ROLLIPOP_HMR_CLIENT_PATH ?? DEFAULT_HMR_CLIENT_PATH, { paths: [config.root] });
2671
2718
  const replaceHMRClientPlugin = {
2672
2719
  name: "rollipop:react-native-replace-hmr-client",
2673
- resolveId: {
2674
- filter: [include(id(/\/HMRClient\.js$/))],
2675
- async handler(id, importer) {
2676
- const resolvedId = await this.resolve(id, importer, { skipSelf: true });
2677
- if (resolvedId?.id === hmrClientPath) await this.load({ id: resolvedId.id });
2678
- }
2679
- },
2680
2720
  load: {
2681
- filter: [include(id(exactRegex(hmrClientPath)))],
2721
+ filter: [include(id(exactRegex(__require.resolve(process.env.ROLLIPOP_HMR_CLIENT_PATH ?? DEFAULT_HMR_CLIENT_PATH, { paths: [config.root] }))))],
2682
2722
  handler(id) {
2683
2723
  this.debug(`Replacing HMR client: ${id}`);
2684
2724
  return hmrConfig?.clientImplement ?? defaultRuntimeImplements.clientImplement;
@@ -2952,6 +2992,16 @@ function merge$1(target, source, key) {
2952
2992
  function swcPlugin(options) {
2953
2993
  const { rules = [] } = options ?? {};
2954
2994
  const swcOptionsById = /* @__PURE__ */ new Map();
2995
+ const swcHelpersResolvePlugin = {
2996
+ name: "rollipop:swc-helpers-resolve",
2997
+ resolveId: {
2998
+ order: "pre",
2999
+ filter: [include(id(/^@swc\/helpers/)), ROLLDOWN_RUNTIME_EXCLUDE_FILTER],
3000
+ handler(source, _importer, extraOptions) {
3001
+ return this.resolve(source, import.meta.dirname, extraOptions);
3002
+ }
3003
+ }
3004
+ };
2955
3005
  const swcRules = rules.map(({ filter, options }, index) => {
2956
3006
  return {
2957
3007
  name: `rollipop:swc-rule-${index}`,
@@ -2970,27 +3020,30 @@ function swcPlugin(options) {
2970
3020
  buildStart() {
2971
3021
  swcOptionsById.clear();
2972
3022
  },
2973
- transform: { handler(code, id) {
2974
- if (getFlag(this, id) & TransformFlag.SKIP_ALL) return;
2975
- const swcOptions = swcOptionsById.get(id) ?? [];
2976
- const baseOptions = getPreset();
2977
- const result = swc.transformSync(code, {
2978
- filename: id,
2979
- configFile: false,
2980
- swcrc: false,
2981
- sourceMaps: true,
2982
- inputSourceMap: false,
2983
- ...mergeSwcOptions(baseOptions, ...swcOptions)
2984
- });
2985
- return {
2986
- code: result.code,
2987
- map: result.map
2988
- };
2989
- } }
3023
+ transform: {
3024
+ filter: [ROLLDOWN_RUNTIME_EXCLUDE_FILTER],
3025
+ handler(code, id) {
3026
+ if (getFlag(this, id) & TransformFlag.SKIP_ALL) return;
3027
+ const swcOptions = swcOptionsById.get(id) ?? [];
3028
+ const baseOptions = getPreset(id);
3029
+ const result = swc.transformSync(code, {
3030
+ filename: id,
3031
+ configFile: false,
3032
+ swcrc: false,
3033
+ sourceMaps: true,
3034
+ inputSourceMap: false,
3035
+ ...mergeSwcOptions(baseOptions, ...swcOptions)
3036
+ });
3037
+ return {
3038
+ code: result.code,
3039
+ map: result.map
3040
+ };
3041
+ }
3042
+ }
2990
3043
  };
2991
- return [...swcRules, swcPlugin].map(cacheable);
3044
+ return [swcHelpersResolvePlugin, ...[...swcRules, swcPlugin].map(cacheable)];
2992
3045
  }
2993
- function getPreset() {
3046
+ function getPreset(id) {
2994
3047
  return {
2995
3048
  jsc: {
2996
3049
  target: "es5",
@@ -3004,9 +3057,10 @@ function getPreset() {
3004
3057
  assumptions: {
3005
3058
  setPublicClassFields: true,
3006
3059
  privateFieldsAsProperties: true
3007
- }
3060
+ },
3061
+ externalHelpers: true
3008
3062
  },
3009
- isModule: true
3063
+ isModule: id.endsWith(".cjs") ? "commonjs" : true
3010
3064
  };
3011
3065
  }
3012
3066
 
@@ -3145,10 +3199,13 @@ async function resolveRolldownOptions(context, config, buildOptions, devEngineOp
3145
3199
  tsconfig: config.tsconfig,
3146
3200
  resolve: mergedResolveOptions,
3147
3201
  transform: mergedTransformOptions,
3148
- optimization: rolldownOptimization,
3149
3202
  treeshake: rolldownTreeshake,
3150
3203
  external: rolldownExternal,
3151
3204
  shimMissingExports: rolldownShimMissingExports,
3205
+ optimization: {
3206
+ ...rolldownOptimization,
3207
+ inlineConst: false
3208
+ },
3152
3209
  experimental: { lazyBarrel: rolldownLazyBarrel },
3153
3210
  plugins: withTransformBoundary([
3154
3211
  preludePlugin({ modulePaths: preludePaths }),
@@ -3343,7 +3400,7 @@ async function runServer(config, options) {
3343
3400
 
3344
3401
  //#endregion
3345
3402
  //#region package.json
3346
- var version = "0.1.0-alpha.13";
3403
+ var version = "0.1.0-alpha.14";
3347
3404
 
3348
3405
  //#endregion
3349
3406
  //#region src/node/logger.ts
@@ -3,8 +3,9 @@ import { ChalkInstance } from "chalk";
3
3
  import * as fastifyMiddie from "@fastify/middie";
4
4
  import * as rolldown from "@rollipop/rolldown";
5
5
  import { RollupLogWithString } from "@rollipop/rolldown";
6
- import { DevWatchOptions, TransformOptions } from "@rollipop/rolldown/experimental";
6
+ import { DevWatchOptions } from "@rollipop/rolldown/experimental";
7
7
  import * as babel from "@babel/core";
8
+ import { TransformOptions } from "@rollipop/rolldown/utils";
8
9
  import * as swc from "@swc/core";
9
10
  import { FastifyInstance } from "fastify";
10
11
  import { Emitter } from "mitt";
@@ -1,4 +1,4 @@
1
- import "@rollipop/rolldown-pluginutils";
1
+ import { exclude, id, or } from "@rollipop/rolldown-pluginutils";
2
2
  import chalk from "chalk";
3
3
  import dayjs from "dayjs";
4
4
  import { invariant } from "es-toolkit";
@@ -10,7 +10,7 @@ export * from "@rollipop/rolldown-pluginutils"
10
10
  const DEBUG_KEY = "rollipop";
11
11
 
12
12
  //#endregion
13
- //#region src/common/debug.ts
13
+ //#region src/common/env.ts
14
14
  const TRUTHY_VALUES = [
15
15
  "yes",
16
16
  "on",
@@ -122,6 +122,10 @@ var Logger = class Logger {
122
122
  //#region src/logger.ts
123
123
  const logger = new Logger("bundler");
124
124
 
125
+ //#endregion
126
+ //#region src/core/plugins/shared/filters.ts
127
+ const ROLLDOWN_RUNTIME_EXCLUDE_FILTER = exclude(or(id(/rolldown\/runtime/), id(/@oxc-project\+runtime/)));
128
+
125
129
  //#endregion
126
130
  //#region src/core/plugins/utils/transform-utils.ts
127
131
  const TRANSFORM_FLAGS_KEY = Symbol("transform-flags");
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "rollipop",
3
- "version": "0.1.0-alpha.13",
3
+ "version": "0.1.0-alpha.14",
4
4
  "homepage": "https://github.com/leegeunhyeok/rollipop#readme",
5
5
  "bugs": {
6
6
  "url": "https://github.com/leegeunhyeok/rollipop/issues"
@@ -65,50 +65,51 @@
65
65
  "build": "tsdown"
66
66
  },
67
67
  "dependencies": {
68
- "@babel/code-frame": "^7.27.1",
69
- "@babel/core": "^7.28.5",
70
- "@babel/generator": "^7.28.5",
68
+ "@babel/code-frame": "^7.29.0",
69
+ "@babel/core": "^7.29.0",
70
+ "@babel/generator": "^7.29.1",
71
71
  "@babel/plugin-transform-flow-strip-types": "^7.27.1",
72
- "@babel/plugin-transform-typescript": "^7.28.5",
72
+ "@babel/plugin-transform-typescript": "^7.28.6",
73
73
  "@commander-js/extra-typings": "^14.0.0",
74
- "@fastify/middie": "^9.0.3",
75
- "@inquirer/prompts": "^8.1.0",
74
+ "@fastify/middie": "^9.3.1",
75
+ "@inquirer/prompts": "^8.3.0",
76
76
  "@node-rs/xxhash": "^1.7.6",
77
- "@react-native-community/cli-server-api": "^20.0.2",
78
- "@react-native-community/cli-types": "^20.1.0",
79
- "@react-native/babel-plugin-codegen": "^0.83.1",
80
- "@react-native/dev-middleware": "^0.83.1",
81
- "@rollipop/rolldown": "1.0.0-rc.3",
82
- "@rollipop/rolldown-pluginutils": "1.0.0-rc.3",
77
+ "@react-native-community/cli-server-api": "^20.1.2",
78
+ "@react-native-community/cli-types": "^20.1.2",
79
+ "@react-native/babel-plugin-codegen": "^0.84.1",
80
+ "@react-native/dev-middleware": "^0.84.1",
81
+ "@rollipop/rolldown": "1.0.0-rc.4",
82
+ "@rollipop/rolldown-pluginutils": "1.0.0-rc.4",
83
83
  "@svgr/core": "^8.1.0",
84
84
  "@svgr/plugin-jsx": "^8.1.0",
85
- "@swc/core": "^1.15.7",
85
+ "@swc/core": "^1.15.18",
86
+ "@swc/helpers": "^0.5.19",
86
87
  "@types/ws": "^8",
87
- "ajv": "^8.17.1",
88
- "babel-plugin-syntax-hermes-parser": "^0.33.2",
88
+ "ajv": "^8.18.0",
89
+ "babel-plugin-syntax-hermes-parser": "^0.33.3",
89
90
  "c12": "^3.3.3",
90
91
  "chalk": "^5.6.2",
91
- "commander": "^14.0.2",
92
+ "commander": "^14.0.3",
92
93
  "dayjs": "^1.11.19",
93
- "dedent": "^1.7.1",
94
- "dotenv": "^17.2.3",
94
+ "dedent": "^1.7.2",
95
+ "dotenv": "^17.3.1",
95
96
  "dotenv-expand": "^12.0.3",
96
- "es-toolkit": "^1.44.0",
97
- "fastify": "^5.6.2",
97
+ "es-toolkit": "^1.45.1",
98
+ "fastify": "^5.8.1",
98
99
  "fastify-plugin": "^5.1.0",
99
- "flow-remove-types": "^2.295.0",
100
+ "flow-remove-types": "^2.304.0",
100
101
  "gradient-string": "^3.0.0",
101
- "hermes-parser": "^0.33.0",
102
+ "hermes-parser": "^0.33.3",
102
103
  "image-size": "^2.0.2",
103
104
  "json-schema-to-ts": "^3.1.1",
104
105
  "mime": "^4.1.0",
105
106
  "mitt": "^3.0.1",
106
- "p-limit": "^7.2.0",
107
+ "p-limit": "^7.3.0",
107
108
  "source-map": "^0.7.6",
108
- "strip-ansi": "^7.1.2",
109
+ "strip-ansi": "^7.2.0",
109
110
  "url": "^0.11.4",
110
- "wrap-ansi": "^9.0.2",
111
- "ws": "^8.18.3"
111
+ "wrap-ansi": "^10.0.0",
112
+ "ws": "^8.19.0"
112
113
  },
113
114
  "devDependencies": {
114
115
  "@types/babel__code-frame": "^7",