@rspack/core 1.3.1 → 1.3.2

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.
@@ -813,7 +813,26 @@ interface ReactConfig {
813
813
  /**
814
814
  * Enable fast refresh feature for React app
815
815
  */
816
- refresh?: boolean;
816
+ refresh?: boolean | {
817
+ /**
818
+ * Identifier for the `react-refresh` register function.
819
+ *
820
+ * Defaults to `$RefreshReg$`
821
+ */
822
+ refreshReg?: string;
823
+ /**
824
+ * Identifier for the `react-refresh` signature function.
825
+ *
826
+ * Defaults to `$RefreshSig$`
827
+ */
828
+ refreshSig?: string;
829
+ /**
830
+ * Flag to emit full signatures.
831
+ *
832
+ * Defaults to `false`
833
+ */
834
+ emitFullSignatures?: boolean;
835
+ };
817
836
  /**
818
837
  * jsx runtime
819
838
  */
@@ -1020,6 +1039,12 @@ interface BaseModuleConfig {
1020
1039
  * ```
1021
1040
  */
1022
1041
  importInterop?: "swc" | "babel" | "node" | "none";
1042
+ /**
1043
+ * Output extension for generated files.
1044
+ *
1045
+ * Defaults to `js`.
1046
+ */
1047
+ outFileExtension?: "js" | "mjs" | "cjs";
1023
1048
  /**
1024
1049
  * Emits `cjs-module-lexer` annotation
1025
1050
  * `cjs-module-lexer` is used in Node.js core for detecting the named exports available when importing a CJS module into ESM.
@@ -1 +1 @@
1
- {"name":"@swc/types","author":"강동윤 <kdy1997.dev@gmail.com>","version":"0.1.19","license":"Apache-2.0","types":"index.d.ts","type":"commonjs"}
1
+ {"name":"@swc/types","author":"강동윤 <kdy1997.dev@gmail.com>","version":"0.1.20","license":"Apache-2.0","types":"index.d.ts","type":"commonjs"}
package/dist/index.js CHANGED
@@ -5354,10 +5354,14 @@ var run = async (task, options) => ensureLoaderWorkerPool().then(async (pool2) =
5354
5354
  switch (message.requestType) {
5355
5355
  case "WaitForPendingRequest" /* WaitForPendingRequest */: {
5356
5356
  const pendingRequestId = message.data[0];
5357
- const ids = Array.isArray(pendingRequestId) ? pendingRequestId : [pendingRequestId];
5357
+ const isArray = Array.isArray(pendingRequestId);
5358
+ const ids = isArray ? pendingRequestId : [pendingRequestId];
5358
5359
  result2 = await Promise.all(
5359
5360
  ids.map((id) => pendingRequests.get(id))
5360
5361
  );
5362
+ if (!isArray) {
5363
+ result2 = result2[0];
5364
+ }
5361
5365
  break;
5362
5366
  }
5363
5367
  default:
@@ -6078,6 +6082,7 @@ async function runLoaders(compiler, context2) {
6078
6082
  get: () => context2.__internal__parseMeta
6079
6083
  });
6080
6084
  const getWorkerLoaderContext = () => {
6085
+ const normalModule = loaderContext._module instanceof import_binding2.NormalModule ? loaderContext._module : void 0;
6081
6086
  const workerLoaderContext = {
6082
6087
  hot: loaderContext.hot,
6083
6088
  context: loaderContext.context,
@@ -6109,11 +6114,27 @@ async function runLoaders(compiler, context2) {
6109
6114
  }
6110
6115
  },
6111
6116
  _compilation: {
6112
- outputOptions: compiler._lastCompilation.outputOptions
6117
+ options: {
6118
+ output: {
6119
+ // css-loader
6120
+ environment: compiler._lastCompilation.outputOptions.environment
6121
+ }
6122
+ },
6123
+ // css-loader
6124
+ outputOptions: {
6125
+ hashSalt: compiler._lastCompilation.outputOptions.hashSalt,
6126
+ hashFunction: compiler._lastCompilation.outputOptions.hashFunction,
6127
+ hashDigest: compiler._lastCompilation.outputOptions.hashDigest,
6128
+ hashDigestLength: compiler._lastCompilation.outputOptions.hashDigestLength
6129
+ }
6113
6130
  },
6114
6131
  _module: {
6115
6132
  type: loaderContext._module.type,
6116
- identifier: loaderContext._module.identifier()
6133
+ identifier: loaderContext._module.identifier(),
6134
+ matchResource: normalModule == null ? void 0 : normalModule.matchResource,
6135
+ request: normalModule == null ? void 0 : normalModule.request,
6136
+ userRequest: normalModule == null ? void 0 : normalModule.userRequest,
6137
+ rawRequest: normalModule == null ? void 0 : normalModule.rawRequest
6117
6138
  }
6118
6139
  };
6119
6140
  Object.assign(workerLoaderContext, compiler.options.loader);
@@ -6207,6 +6228,9 @@ async function runLoaders(compiler, context2) {
6207
6228
  loaderContext.cacheable(cacheable);
6208
6229
  break;
6209
6230
  }
6231
+ case "ImportModule" /* ImportModule */: {
6232
+ return loaderContext.importModule(args[0], args[1]);
6233
+ }
6210
6234
  case "UpdateLoaderObjects" /* UpdateLoaderObjects */: {
6211
6235
  const updates = args[0];
6212
6236
  loaderContext.loaders = loaderContext.loaders.map((item, index) => {
@@ -6222,6 +6246,29 @@ async function runLoaders(compiler, context2) {
6222
6246
  });
6223
6247
  break;
6224
6248
  }
6249
+ case "CompilationGetPath" /* CompilationGetPath */: {
6250
+ const filename2 = args[0];
6251
+ const data = args[1];
6252
+ return compiler._lastCompilation.getPath(filename2, data);
6253
+ }
6254
+ case "CompilationGetPathWithInfo" /* CompilationGetPathWithInfo */: {
6255
+ const filename2 = args[0];
6256
+ const data = args[1];
6257
+ return compiler._lastCompilation.getPathWithInfo(filename2, data);
6258
+ }
6259
+ case "CompilationGetAssetPath" /* CompilationGetAssetPath */: {
6260
+ const filename2 = args[0];
6261
+ const data = args[1];
6262
+ return compiler._lastCompilation.getAssetPath(filename2, data);
6263
+ }
6264
+ case "CompilationGetAssetPathWithInfo" /* CompilationGetAssetPathWithInfo */: {
6265
+ const filename2 = args[0];
6266
+ const data = args[1];
6267
+ return compiler._lastCompilation.getAssetPathWithInfo(
6268
+ filename2,
6269
+ data
6270
+ );
6271
+ }
6225
6272
  default: {
6226
6273
  throw new Error(`Unknown request type: ${requestType}`);
6227
6274
  }
@@ -13124,15 +13171,17 @@ var createCompilationHooksRegisters = (getCompiler, createTap, createMapTap) =>
13124
13171
  function(queried) {
13125
13172
  return function({
13126
13173
  chunk: chunkBinding,
13174
+ allRuntimeRequirements,
13127
13175
  runtimeRequirements
13128
13176
  }) {
13129
13177
  const set = __from_binding_runtime_globals(runtimeRequirements);
13178
+ const all = __from_binding_runtime_globals(allRuntimeRequirements);
13130
13179
  const chunk = Chunk.__from_binding(chunkBinding);
13131
13180
  for (const r of set) {
13132
- queried.for(r).call(chunk, set);
13181
+ queried.for(r).call(chunk, all);
13133
13182
  }
13134
13183
  return {
13135
- runtimeRequirements: __to_binding_runtime_globals(set)
13184
+ allRuntimeRequirements: __to_binding_runtime_globals(all)
13136
13185
  };
13137
13186
  };
13138
13187
  }
@@ -51,7 +51,12 @@ export declare enum RequestType {
51
51
  EmitFile = "EmitFile",
52
52
  EmitDiagnostic = "EmitDiagnostic",
53
53
  SetCacheable = "SetCacheable",
54
- UpdateLoaderObjects = "UpdateLoaderObjects"
54
+ ImportModule = "ImportModule",
55
+ UpdateLoaderObjects = "UpdateLoaderObjects",
56
+ CompilationGetPath = "CompilationGetPath",
57
+ CompilationGetPathWithInfo = "CompilationGetPathWithInfo",
58
+ CompilationGetAssetPath = "CompilationGetAssetPath",
59
+ CompilationGetAssetPathWithInfo = "CompilationGetAssetPathWithInfo"
55
60
  }
56
61
  export declare enum RequestSyncType {
57
62
  WaitForPendingRequest = "WaitForPendingRequest"
package/dist/worker.js CHANGED
@@ -1461,9 +1461,6 @@ async function loaderImpl({ args, loaderContext, loaderState }, sendRequest, wai
1461
1461
  loaderContext.clearDependencies = function clearDependencies() {
1462
1462
  pendingDependencyRequest.push(sendRequest("ClearDependencies" /* ClearDependencies */));
1463
1463
  };
1464
- loaderContext.importModule = function() {
1465
- throw new Error("importModule is not supported in worker");
1466
- };
1467
1464
  loaderContext.resolve = function resolve(context, request, callback) {
1468
1465
  sendRequest("Resolve" /* Resolve */, context, request).then(
1469
1466
  (result) => {
@@ -1598,7 +1595,7 @@ async function loaderImpl({ args, loaderContext, loaderState }, sendRequest, wai
1598
1595
  };
1599
1596
  loaderContext._compiler = {
1600
1597
  ...loaderContext._compiler,
1601
- // @ts-ignore
1598
+ // @ts-expect-error: some properties are missing.
1602
1599
  webpack: {
1603
1600
  util: {
1604
1601
  createHash: (init_createHash(), __toCommonJS(createHash_exports)).createHash,
@@ -1606,13 +1603,67 @@ async function loaderImpl({ args, loaderContext, loaderState }, sendRequest, wai
1606
1603
  }
1607
1604
  }
1608
1605
  };
1606
+ loaderContext._compilation = {
1607
+ ...loaderContext._compilation,
1608
+ getPath(filename, data) {
1609
+ return sendRequest("CompilationGetPath" /* CompilationGetPath */, filename, data).wait();
1610
+ },
1611
+ getPathWithInfo(filename, data) {
1612
+ return sendRequest(
1613
+ "CompilationGetPathWithInfo" /* CompilationGetPathWithInfo */,
1614
+ filename,
1615
+ data
1616
+ ).wait();
1617
+ },
1618
+ getAssetPath(filename, data) {
1619
+ return sendRequest(
1620
+ "CompilationGetAssetPath" /* CompilationGetAssetPath */,
1621
+ filename,
1622
+ data
1623
+ ).wait();
1624
+ },
1625
+ getAssetPathWithInfo(filename, data) {
1626
+ return sendRequest(
1627
+ "CompilationGetAssetPathWithInfo" /* CompilationGetAssetPathWithInfo */,
1628
+ filename,
1629
+ data
1630
+ ).wait();
1631
+ }
1632
+ };
1609
1633
  const _module = loaderContext._module;
1610
1634
  loaderContext._module = {
1611
1635
  type: _module.type,
1612
1636
  identifier() {
1613
1637
  return _module.identifier;
1638
+ },
1639
+ matchResource: _module.matchResource,
1640
+ request: _module.request,
1641
+ userRequest: _module.userRequest,
1642
+ rawRequest: _module.rawRequest
1643
+ };
1644
+ loaderContext.importModule = function importModule(request, options, callback) {
1645
+ if (!callback) {
1646
+ return new Promise((resolve, reject) => {
1647
+ sendRequest("ImportModule" /* ImportModule */, request, options).then(
1648
+ (result) => {
1649
+ resolve(result);
1650
+ },
1651
+ (err) => {
1652
+ reject(err);
1653
+ }
1654
+ );
1655
+ });
1614
1656
  }
1657
+ sendRequest("ImportModule" /* ImportModule */, request, options).then(
1658
+ (result) => {
1659
+ callback(null, result);
1660
+ },
1661
+ (err) => {
1662
+ callback(err);
1663
+ }
1664
+ );
1615
1665
  };
1666
+ loaderContext.fs = require("fs");
1616
1667
  Object.defineProperty(loaderContext, "request", {
1617
1668
  enumerable: true,
1618
1669
  get: () => loaderContext.loaders.map((o) => o.request).concat(loaderContext.resource || "").join("!")
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@rspack/core",
3
- "version": "1.3.1",
3
+ "version": "1.3.2",
4
4
  "webpackVersion": "5.75.0",
5
5
  "license": "MIT",
6
6
  "description": "The fast Rust-based web bundler with webpack-compatible API",
@@ -37,8 +37,8 @@
37
37
  "directory": "packages/rspack"
38
38
  },
39
39
  "devDependencies": {
40
- "@swc/core": "1.11.11",
41
- "@swc/types": "0.1.19",
40
+ "@swc/core": "1.11.13",
41
+ "@swc/types": "0.1.20",
42
42
  "@types/graceful-fs": "4.1.9",
43
43
  "@types/watchpack": "^2.4.4",
44
44
  "@types/webpack-sources": "3.2.3",
@@ -48,23 +48,23 @@
48
48
  "graceful-fs": "^4.2.11",
49
49
  "json-parse-even-better-errors": "^3.0.2",
50
50
  "prebundle": "^1.2.7",
51
- "tsc-alias": "^1.8.11",
51
+ "tsc-alias": "^1.8.13",
52
52
  "tsup": "^8.4.0",
53
53
  "tsx": "^4.19.3",
54
54
  "typescript": "^5.7.3",
55
55
  "watchpack": "^2.4.2",
56
- "webpack-dev-server": "5.2.0",
56
+ "webpack-dev-server": "5.2.1",
57
57
  "webpack-sources": "3.2.3",
58
58
  "zod": "^3.24.2",
59
59
  "zod-validation-error": "3.4.0",
60
- "@rspack/tracing": "1.3.1"
60
+ "@rspack/tracing": "1.3.2"
61
61
  },
62
62
  "dependencies": {
63
- "@module-federation/runtime-tools": "0.11.1",
63
+ "@module-federation/runtime-tools": "0.11.2",
64
64
  "@rspack/lite-tapable": "1.0.1",
65
- "caniuse-lite": "^1.0.30001706",
65
+ "caniuse-lite": "^1.0.30001707",
66
66
  "tinypool": "^1.0.2",
67
- "@rspack/binding": "1.3.1"
67
+ "@rspack/binding": "1.3.2"
68
68
  },
69
69
  "peerDependencies": {
70
70
  "@rspack/tracing": "^1.x",