@rspack/core 1.4.11 → 1.5.0-beta.0

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 (84) hide show
  1. package/dist/Compilation.d.ts +2 -2
  2. package/dist/Compiler.d.ts +5 -0
  3. package/dist/NativeWatchFileSystem.d.ts +3 -1
  4. package/dist/NormalModuleFactory.d.ts +2 -2
  5. package/dist/Resolver.d.ts +0 -6
  6. package/dist/ResolverFactory.d.ts +8 -5
  7. package/dist/VirtualModulesPlugin.d.ts +12 -0
  8. package/dist/builtin-plugin/APIPlugin.d.ts +1 -1
  9. package/dist/builtin-plugin/ArrayPushCallbackChunkFormatPlugin.d.ts +1 -1
  10. package/dist/builtin-plugin/AssetModulesPlugin.d.ts +1 -1
  11. package/dist/builtin-plugin/AsyncWebAssemblyModulesPlugin.d.ts +1 -1
  12. package/dist/builtin-plugin/BannerPlugin.d.ts +1 -1
  13. package/dist/builtin-plugin/BundlerInfoRspackPlugin.d.ts +1 -1
  14. package/dist/builtin-plugin/ChunkPrefetchPreloadPlugin.d.ts +1 -1
  15. package/dist/builtin-plugin/CommonJsChunkFormatPlugin.d.ts +1 -1
  16. package/dist/builtin-plugin/ContextReplacementPlugin.d.ts +1 -1
  17. package/dist/builtin-plugin/CopyRspackPlugin.d.ts +1 -1
  18. package/dist/builtin-plugin/CssChunkingPlugin.d.ts +1 -1
  19. package/dist/builtin-plugin/CssModulesPlugin.d.ts +1 -1
  20. package/dist/builtin-plugin/DataUriPlugin.d.ts +1 -1
  21. package/dist/builtin-plugin/DefinePlugin.d.ts +1 -1
  22. package/dist/builtin-plugin/DllEntryPlugin.d.ts +1 -1
  23. package/dist/builtin-plugin/DllReferenceAgencyPlugin.d.ts +1 -1
  24. package/dist/builtin-plugin/ElectronTargetPlugin.d.ts +1 -1
  25. package/dist/builtin-plugin/EnableChunkLoadingPlugin.d.ts +1 -1
  26. package/dist/builtin-plugin/EnableWasmLoadingPlugin.d.ts +1 -1
  27. package/dist/builtin-plugin/EnsureChunkConditionsPlugin.d.ts +1 -1
  28. package/dist/builtin-plugin/EntryPlugin.d.ts +1 -1
  29. package/dist/builtin-plugin/EvalDevToolModulePlugin.d.ts +1 -1
  30. package/dist/builtin-plugin/EvalSourceMapDevToolPlugin.d.ts +1 -1
  31. package/dist/builtin-plugin/FetchCompileAsyncWasmPlugin.d.ts +1 -1
  32. package/dist/builtin-plugin/FileUriPlugin.d.ts +1 -1
  33. package/dist/builtin-plugin/FlagAllModulesAsUsedPlugin.d.ts +1 -1
  34. package/dist/builtin-plugin/FlagDependencyExportsPlugin.d.ts +1 -1
  35. package/dist/builtin-plugin/HttpExternalsRspackPlugin.d.ts +1 -1
  36. package/dist/builtin-plugin/IgnorePlugin.d.ts +1 -1
  37. package/dist/builtin-plugin/InferAsyncModulesPlugin.d.ts +1 -1
  38. package/dist/builtin-plugin/JsLoaderRspackPlugin.d.ts +1 -1
  39. package/dist/builtin-plugin/JsonModulesPlugin.d.ts +1 -1
  40. package/dist/builtin-plugin/LibManifestPlugin.d.ts +1 -1
  41. package/dist/builtin-plugin/LightningCssMinimizerRspackPlugin.d.ts +1 -1
  42. package/dist/builtin-plugin/LimitChunkCountPlugin.d.ts +1 -1
  43. package/dist/builtin-plugin/MergeDuplicateChunksPlugin.d.ts +1 -1
  44. package/dist/builtin-plugin/ModuleChunkFormatPlugin.d.ts +1 -1
  45. package/dist/builtin-plugin/ModuleInfoHeaderPlugin.d.ts +1 -1
  46. package/dist/builtin-plugin/NamedChunkIdsPlugin.d.ts +1 -1
  47. package/dist/builtin-plugin/NamedModuleIdsPlugin.d.ts +1 -1
  48. package/dist/builtin-plugin/NoEmitOnErrorsPlugin.d.ts +1 -1
  49. package/dist/builtin-plugin/NodeTargetPlugin.d.ts +1 -1
  50. package/dist/builtin-plugin/OccurrenceChunkIdsPlugin.d.ts +1 -1
  51. package/dist/builtin-plugin/ProgressPlugin.d.ts +1 -1
  52. package/dist/builtin-plugin/ProvidePlugin.d.ts +1 -1
  53. package/dist/builtin-plugin/RealContentHashPlugin.d.ts +1 -1
  54. package/dist/builtin-plugin/RemoveDuplicateModulesPlugin.d.ts +1 -1
  55. package/dist/builtin-plugin/RemoveEmptyChunksPlugin.d.ts +1 -1
  56. package/dist/builtin-plugin/RsdoctorPlugin.d.ts +1 -1
  57. package/dist/builtin-plugin/RslibPlugin.d.ts +1 -1
  58. package/dist/builtin-plugin/RstestPlugin.d.ts +1 -1
  59. package/dist/builtin-plugin/RuntimeChunkPlugin.d.ts +1 -1
  60. package/dist/builtin-plugin/RuntimePlugin.d.ts +1 -1
  61. package/dist/builtin-plugin/SideEffectsFlagPlugin.d.ts +1 -1
  62. package/dist/builtin-plugin/SizeLimitsPlugin.d.ts +1 -1
  63. package/dist/builtin-plugin/SourceMapDevToolPlugin.d.ts +1 -1
  64. package/dist/builtin-plugin/SubresourceIntegrityPlugin.d.ts +1 -1
  65. package/dist/builtin-plugin/SwcJsMinimizerPlugin.d.ts +1 -1
  66. package/dist/builtin-plugin/WarnCaseSensitiveModulesPlugin.d.ts +1 -1
  67. package/dist/builtin-plugin/base.d.ts +2 -2
  68. package/dist/builtin-plugin/html-plugin/plugin.d.ts +1 -1
  69. package/dist/builtin-plugin/lazy-compilation/lazyCompilation.d.ts +1 -1
  70. package/dist/config/normalization.d.ts +7 -0
  71. package/dist/config/types.d.ts +15 -4
  72. package/dist/container/ModuleFederationRuntimePlugin.d.ts +1 -1
  73. package/dist/exports.d.ts +9 -1
  74. package/dist/index.js +248 -154
  75. package/dist/loader-runner/loadLoader.d.ts +2 -1
  76. package/dist/loader-runner/utils.d.ts +2 -1
  77. package/dist/schema/config.d.ts +56 -47
  78. package/dist/schema/loaders.d.ts +5 -5
  79. package/dist/schema/plugins.d.ts +10 -10
  80. package/dist/util/bindingVersionCheck.d.ts +1 -1
  81. package/dist/util/require.d.ts +3 -0
  82. package/dist/worker.js +44 -9
  83. package/module.d.ts +9 -10
  84. package/package.json +8 -5
package/dist/worker.js CHANGED
@@ -1,5 +1,30 @@
1
1
  "use strict";
2
2
  var __webpack_modules__ = {
3
+ "./src/swc.ts": function(__unused_webpack_module, __webpack_exports__, __webpack_require__) {
4
+ __webpack_require__.r(__webpack_exports__), __webpack_require__.d(__webpack_exports__, {
5
+ minify: ()=>minify,
6
+ minifySync: ()=>minifySync,
7
+ transform: ()=>transform,
8
+ transformSync: ()=>transformSync
9
+ });
10
+ var _rspack_binding__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__("@rspack/binding"), _rspack_binding__WEBPACK_IMPORTED_MODULE_0___default = __webpack_require__.n(_rspack_binding__WEBPACK_IMPORTED_MODULE_0__);
11
+ async function minify(source, options) {
12
+ let _options = JSON.stringify(options || {});
13
+ return _rspack_binding__WEBPACK_IMPORTED_MODULE_0___default().minify(source, _options);
14
+ }
15
+ function minifySync(source, options) {
16
+ let _options = JSON.stringify(options || {});
17
+ return _rspack_binding__WEBPACK_IMPORTED_MODULE_0___default().minifySync(source, _options);
18
+ }
19
+ async function transform(source, options) {
20
+ let _options = JSON.stringify(options || {});
21
+ return _rspack_binding__WEBPACK_IMPORTED_MODULE_0___default().transform(source, _options);
22
+ }
23
+ function transformSync(source, options) {
24
+ let _options = JSON.stringify(options || {});
25
+ return _rspack_binding__WEBPACK_IMPORTED_MODULE_0___default().transformSync(source, _options);
26
+ }
27
+ },
3
28
  "./src/util/cleverMerge.ts": function(__unused_webpack_module, __webpack_exports__, __webpack_require__) {
4
29
  __webpack_require__.d(__webpack_exports__, {
5
30
  R_: ()=>cleverMerge
@@ -386,6 +411,9 @@ var __webpack_modules__ = {
386
411
  }
387
412
  };
388
413
  },
414
+ "@rspack/binding": function(module) {
415
+ module.exports = require("@rspack/binding");
416
+ },
389
417
  "node:fs": function(module) {
390
418
  module.exports = require("node:fs");
391
419
  },
@@ -437,8 +465,8 @@ for(var __webpack_i__ in (()=>{
437
465
  });
438
466
  let external_node_querystring_namespaceObject = require("node:querystring");
439
467
  var RequestType, RequestSyncType, external_node_querystring_default = __webpack_require__.n(external_node_querystring_namespaceObject), external_node_util_ = __webpack_require__("node:util");
440
- let external_node_worker_threads_namespaceObject = require("node:worker_threads"), binding_namespaceObject = require("@rspack/binding");
441
- var createHash = __webpack_require__("./src/util/createHash.ts");
468
+ let external_node_worker_threads_namespaceObject = require("node:worker_threads");
469
+ var binding_ = __webpack_require__("@rspack/binding"), createHash = __webpack_require__("./src/util/createHash.ts");
442
470
  let external_node_path_namespaceObject = require("node:path");
443
471
  var external_node_path_default = __webpack_require__.n(external_node_path_namespaceObject);
444
472
  let WINDOWS_ABS_PATH_REGEXP = /^[a-zA-Z]:[\\/]/, SEGMENTS_SPLIT_REGEXP = /([|!])/, WINDOWS_PATH_SEPARATOR_REGEXP = /\\/g, relativePathToRequest = (relativePath)=>"" === relativePath ? "./." : ".." === relativePath ? "../." : relativePath.startsWith("../") ? relativePath : `./${relativePath}`, absoluteToRequest = (context, maybeAbsolutePath)=>{
@@ -531,12 +559,14 @@ for(var __webpack_i__ in (()=>{
531
559
  let memoize = (fn)=>{
532
560
  let result, cache = !1, callback = fn;
533
561
  return ()=>(cache || (result = callback(), cache = !0, callback = void 0), result);
534
- }, LoaderLoadingError = class extends Error {
562
+ };
563
+ __webpack_require__("node:fs");
564
+ let LoaderLoadingError = class extends Error {
535
565
  constructor(message){
536
566
  super(message), this.name = "LoaderRunnerError", Error.captureStackTrace(this, this.constructor);
537
567
  }
538
568
  };
539
- function loadLoader(loader, callback) {
569
+ function loadLoader(loader, compiler, callback) {
540
570
  if ("module" === loader.type) try {
541
571
  void 0 === url && (url = __webpack_require__("node:url")), import(url.pathToFileURL(loader.path).toString()).then((module)=>{
542
572
  handleResult(loader, module, callback);
@@ -550,7 +580,7 @@ for(var __webpack_i__ in (()=>{
550
580
  try {
551
581
  module = require(loader.path);
552
582
  } catch (e) {
553
- if (e instanceof Error && "EMFILE" === e.code) return void setImmediate(loadLoader.bind(null, loader, callback));
583
+ if (e instanceof Error && "EMFILE" === e.code) return void setImmediate(loadLoader.bind(null, loader, compiler, callback));
554
584
  return callback(e);
555
585
  }
556
586
  return handleResult(loader, module, callback);
@@ -756,6 +786,11 @@ for(var __webpack_i__ in (()=>{
756
786
  createHash: (type)=>(0, createHash.j)(type || loaderContext._compilation.outputOptions.hashFunction)
757
787
  }, loaderContext._compiler = {
758
788
  ...loaderContext._compiler,
789
+ rspack: {
790
+ experiments: {
791
+ swc: __webpack_require__("./src/swc.ts")
792
+ }
793
+ },
759
794
  webpack: {
760
795
  util: {
761
796
  createHash: __webpack_require__("./src/util/createHash.ts").j,
@@ -830,7 +865,7 @@ for(var __webpack_i__ in (()=>{
830
865
  });
831
866
  let shouldYieldToMainThread = (currentLoaderObject)=>!!(!currentLoaderObject?.parallel || currentLoaderObject?.request.startsWith("builtin:"));
832
867
  switch(loaderState){
833
- case binding_namespaceObject.JsLoaderState.Pitching:
868
+ case binding_.JsLoaderState.Pitching:
834
869
  for(; loaderContext.loaderIndex < loaderContext.loaders.length;){
835
870
  let currentLoaderObject = loaderContext.loaders[loaderContext.loaderIndex];
836
871
  if (shouldYieldToMainThread(currentLoaderObject)) break;
@@ -838,7 +873,7 @@ for(var __webpack_i__ in (()=>{
838
873
  loaderContext.loaderIndex += 1;
839
874
  continue;
840
875
  }
841
- await loadLoaderAsync(currentLoaderObject);
876
+ await loadLoaderAsync(currentLoaderObject, loaderContext._compiler);
842
877
  let fn = currentLoaderObject.pitch;
843
878
  if ((currentLoaderObject.pitchExecuted = !0, fn) && (args = await utils_runSyncOrAsync(fn, loaderContext, [
844
879
  loaderContext.remainingRequest,
@@ -846,7 +881,7 @@ for(var __webpack_i__ in (()=>{
846
881
  currentLoaderObject.loaderItem.data
847
882
  ]) || []).some((value)=>void 0 !== value)) break;
848
883
  }
849
- case binding_namespaceObject.JsLoaderState.Normal:
884
+ case binding_.JsLoaderState.Normal:
850
885
  for(; loaderContext.loaderIndex >= 0;){
851
886
  var args1, raw;
852
887
  let currentLoaderObject = loaderContext.loaders[loaderContext.loaderIndex];
@@ -855,7 +890,7 @@ for(var __webpack_i__ in (()=>{
855
890
  loaderContext.loaderIndex--;
856
891
  continue;
857
892
  }
858
- await loadLoaderAsync(currentLoaderObject);
893
+ await loadLoaderAsync(currentLoaderObject, loaderContext._compiler);
859
894
  let fn = currentLoaderObject.normal;
860
895
  currentLoaderObject.normalExecuted = !0, fn && (args1 = args, !(raw = !!currentLoaderObject.raw) && args1[0] instanceof Uint8Array ? args1[0] = function(buf) {
861
896
  let str = decoder.decode(buf.buffer instanceof SharedArrayBuffer ? Buffer.from(buf) : buf);
package/module.d.ts CHANGED
@@ -111,16 +111,15 @@ declare namespace Rspack {
111
111
  onErrored?: (event: ErroredEvent) => void;
112
112
  }
113
113
 
114
- enum HotUpdateStatus {
115
- idle = "idle",
116
- check = "check",
117
- prepare = "prepare",
118
- ready = "ready",
119
- dispose = "dispose",
120
- apply = "apply",
121
- abort = "abort",
122
- fail = "fail"
123
- }
114
+ type HotUpdateStatus =
115
+ | "idle"
116
+ | "check"
117
+ | "prepare"
118
+ | "ready"
119
+ | "dispose"
120
+ | "apply"
121
+ | "abort"
122
+ | "fail";
124
123
 
125
124
  interface Hot {
126
125
  accept: {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@rspack/core",
3
- "version": "1.4.11",
3
+ "version": "1.5.0-beta.0",
4
4
  "webpackVersion": "5.75.0",
5
5
  "license": "MIT",
6
6
  "description": "The fast Rust-based web bundler with webpack-compatible API",
@@ -27,7 +27,7 @@
27
27
  "module.d.ts"
28
28
  ],
29
29
  "engines": {
30
- "node": ">=16.0.0"
30
+ "node": ">=18.12.0"
31
31
  },
32
32
  "homepage": "https://rspack.rs",
33
33
  "bugs": "https://github.com/web-infra-dev/rspack/issues",
@@ -41,15 +41,17 @@
41
41
  "@rsbuild/core": "^1.4.10",
42
42
  "@rslib/core": "0.11.0",
43
43
  "@swc/types": "0.1.23",
44
+ "@rsbuild/plugin-node-polyfill": "^1.3.0",
44
45
  "@types/graceful-fs": "4.1.9",
45
46
  "@types/watchpack": "^2.4.4",
46
47
  "browserslist-load-config": "^1.0.0",
47
48
  "enhanced-resolve": "5.18.2",
48
49
  "graceful-fs": "^4.2.11",
49
- "prebundle": "^1.3.4",
50
+ "memfs": "4.36.0",
51
+ "prebundle": "^1.4.1",
50
52
  "tinypool": "^1.1.1",
51
53
  "tsx": "^4.20.3",
52
- "typescript": "^5.8.3",
54
+ "typescript": "^5.9.2",
53
55
  "watchpack": "^2.4.4",
54
56
  "webpack-sources": "3.3.3",
55
57
  "glob-to-regexp": "^0.4.1",
@@ -59,7 +61,7 @@
59
61
  "dependencies": {
60
62
  "@module-federation/runtime-tools": "0.17.1",
61
63
  "@rspack/lite-tapable": "1.0.1",
62
- "@rspack/binding": "1.4.11"
64
+ "@rspack/binding": "1.5.0-beta.0"
63
65
  },
64
66
  "peerDependencies": {
65
67
  "@swc/helpers": ">=0.5.1"
@@ -71,6 +73,7 @@
71
73
  },
72
74
  "scripts": {
73
75
  "build": "rslib build",
76
+ "build:browser": "rslib build -c rslib.browser.config.ts",
74
77
  "dev": "rslib build --watch",
75
78
  "doc-coverage": "tsx ./scripts/check-documentation-coverage.ts",
76
79
  "api-extractor": "api-extractor run --verbose",