@rspack-debug/core 2.0.0-canary-20260116 → 2.0.0-rc.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 (107) hide show
  1. package/README.md +1 -1
  2. package/compiled/@rspack/lite-tapable/dist/index.d.ts +175 -0
  3. package/compiled/@rspack/lite-tapable/license +22 -0
  4. package/compiled/@rspack/lite-tapable/package.json +1 -0
  5. package/compiled/@swc/types/index.d.ts +15 -9
  6. package/compiled/@swc/types/package.json +1 -1
  7. package/compiled/connect-next/index.d.ts +56 -0
  8. package/compiled/connect-next/license +26 -0
  9. package/compiled/connect-next/package.json +1 -0
  10. package/compiled/http-proxy-middleware/index.d.ts +544 -0
  11. package/compiled/{browserslist-load-config → http-proxy-middleware}/license +3 -2
  12. package/compiled/http-proxy-middleware/package.json +1 -0
  13. package/compiled/open/index.d.ts +161 -0
  14. package/compiled/open/package.json +1 -0
  15. package/compiled/watchpack/index.d.ts +2 -0
  16. package/compiled/webpack-sources/index.js +188 -131
  17. package/compiled/webpack-sources/package.json +1 -1
  18. package/compiled/webpack-sources/types.d.ts +6 -3
  19. package/dist/BuildInfo.d.ts +1 -1
  20. package/dist/Compilation.d.ts +5 -2
  21. package/dist/Compiler.d.ts +7 -4
  22. package/dist/ContextModuleFactory.d.ts +1 -1
  23. package/dist/FileSystem.d.ts +1 -1
  24. package/dist/Module.d.ts +1 -1
  25. package/dist/ModuleGraph.d.ts +1 -0
  26. package/dist/MultiCompiler.d.ts +1 -1
  27. package/dist/MultiWatching.d.ts +1 -1
  28. package/dist/NativeWatchFileSystem.d.ts +1 -1
  29. package/dist/NormalModule.d.ts +1 -2
  30. package/dist/NormalModuleFactory.d.ts +1 -1
  31. package/dist/RuntimeGlobals.d.ts +1 -1
  32. package/dist/Watching.d.ts +1 -1
  33. package/dist/builtin-loader/lightningcss/index.d.ts +11 -9
  34. package/dist/builtin-loader/lightningcss/target.d.ts +4 -0
  35. package/dist/builtin-loader/swc/index.d.ts +2 -2
  36. package/dist/builtin-loader/swc/pluginImport.d.ts +1 -1
  37. package/dist/builtin-loader/swc/types.d.ts +37 -2
  38. package/dist/builtin-plugin/EsmLibraryPlugin.d.ts +5 -1
  39. package/dist/builtin-plugin/EsmNodeTargetPlugin.d.ts +9 -0
  40. package/dist/builtin-plugin/JavascriptModulesPlugin.d.ts +1 -1
  41. package/dist/builtin-plugin/LightningCssMinimizerRspackPlugin.d.ts +5 -4
  42. package/dist/builtin-plugin/ProgressPlugin.d.ts +5 -4
  43. package/dist/builtin-plugin/RsdoctorPlugin.d.ts +3 -3
  44. package/dist/builtin-plugin/RuntimePlugin.d.ts +1 -1
  45. package/dist/builtin-plugin/SplitChunksPlugin.d.ts +2 -1
  46. package/dist/builtin-plugin/SwcJsMinimizerPlugin.d.ts +3 -2
  47. package/dist/builtin-plugin/WorkerPlugin.d.ts +1 -0
  48. package/dist/builtin-plugin/html-plugin/hooks.d.ts +1 -1
  49. package/dist/builtin-plugin/index.d.ts +2 -0
  50. package/dist/builtin-plugin/lazy-compilation/middleware.d.ts +3 -3
  51. package/dist/builtin-plugin/rsc/Coordinator.d.ts +8 -0
  52. package/dist/builtin-plugin/rsc/RscClientPlugin.d.ts +13 -0
  53. package/dist/builtin-plugin/rsc/RscServerPlugin.d.ts +39 -0
  54. package/dist/builtin-plugin/rsc/index.d.ts +24 -0
  55. package/dist/checkNodeVersion.d.ts +1 -0
  56. package/dist/config/adapterRuleUse.d.ts +2 -1
  57. package/dist/config/defaults.d.ts +4 -2
  58. package/dist/config/devServer.d.ts +102 -237
  59. package/dist/config/normalization.d.ts +2 -3
  60. package/dist/config/target.d.ts +14 -11
  61. package/dist/config/types.d.ts +151 -62
  62. package/dist/container/ContainerPlugin.d.ts +3 -2
  63. package/dist/container/ContainerReferencePlugin.d.ts +4 -3
  64. package/dist/container/ModuleFederationManifestPlugin.d.ts +10 -3
  65. package/dist/container/ModuleFederationPlugin.d.ts +20 -1
  66. package/dist/container/ModuleFederationPluginV1.d.ts +2 -2
  67. package/dist/container/ModuleFederationRuntimePlugin.d.ts +4 -0
  68. package/dist/cssExtractLoader.js +3 -3
  69. package/dist/exports.d.ts +11 -8
  70. package/dist/index.d.ts +1 -0
  71. package/dist/index.js +2074 -707
  72. package/dist/lib/Cache.d.ts +1 -1
  73. package/dist/lib/HookWebpackError.d.ts +1 -1
  74. package/dist/moduleFederationDefaultRuntime.js +1 -1
  75. package/dist/node/NodeWatchFileSystem.d.ts +1 -1
  76. package/dist/rspack.d.ts +1 -1
  77. package/dist/sharing/CollectSharedEntryPlugin.d.ts +22 -0
  78. package/dist/sharing/ConsumeSharedPlugin.d.ts +16 -3
  79. package/dist/sharing/IndependentSharedPlugin.d.ts +35 -0
  80. package/dist/sharing/ProvideSharedPlugin.d.ts +22 -2
  81. package/dist/sharing/SharePlugin.d.ts +43 -5
  82. package/dist/sharing/SharedContainerPlugin.d.ts +23 -0
  83. package/dist/sharing/SharedUsedExportsOptimizerPlugin.d.ts +14 -0
  84. package/dist/sharing/TreeShakingSharedPlugin.d.ts +16 -0
  85. package/dist/sharing/utils.d.ts +1 -0
  86. package/dist/stats/StatsFactory.d.ts +1 -1
  87. package/dist/stats/StatsPrinter.d.ts +1 -1
  88. package/dist/swc.d.ts +2 -2
  89. package/dist/taps/types.d.ts +1 -1
  90. package/dist/util/createHash.d.ts +1 -1
  91. package/dist/util/source.d.ts +1 -1
  92. package/dist/util/supportsColor.d.ts +6 -0
  93. package/dist/util/targetsVersion.d.ts +2 -0
  94. package/dist/worker.js +20 -19
  95. package/hot/dev-server.js +1 -1
  96. package/hot/emitter.js +0 -2
  97. package/hot/lazy-compilation-node.js +91 -34
  98. package/hot/lazy-compilation-web.js +61 -35
  99. package/hot/log.js +0 -2
  100. package/hot/only-dev-server.js +1 -1
  101. package/module.d.ts +4 -2
  102. package/package.json +23 -24
  103. package/compiled/browserslist-load-config/index.d.ts +0 -21
  104. package/compiled/browserslist-load-config/index.js +0 -252
  105. package/compiled/browserslist-load-config/package.json +0 -1
  106. package/dist/builtin-loader/index.d.ts +0 -1
  107. package/dist/rslib-runtime.js +0 -29
@@ -2,51 +2,108 @@ import { createRequire } from 'node:module';
2
2
 
3
3
  var urlBase = decodeURIComponent(__resourceQuery.slice(1));
4
4
  var require = createRequire(import.meta.url);
5
+ var compiling = new Set();
6
+ var errorHandlers = new Set();
5
7
 
6
- /**
7
- * @param {{ data: string, onError: (err: Error) => void, active: boolean, module: module }} options options
8
- * @returns {() => void} function to destroy response
9
- */
10
- export const activate = function (options) {
11
- var data = options.data;
12
- var onError = options.onError;
13
- var active = options.active;
14
- /** @type {import("http").IncomingMessage} */
15
- var response;
16
- var request = (
17
- urlBase.startsWith('https') ? require('https') : require('http')
18
- ).request(
19
- urlBase + encodeURIComponent(data),
8
+ /** @type {import("http").ClientRequest | undefined} */
9
+ var pendingRequest;
10
+ /** @type {boolean} */
11
+ var hasPendingUpdate = false;
12
+
13
+ function sendRequest() {
14
+ if (compiling.size === 0) {
15
+ hasPendingUpdate = false;
16
+ return;
17
+ }
18
+
19
+ var modules = Array.from(compiling);
20
+ var data = modules.join('\n');
21
+
22
+ var httpModule = urlBase.startsWith('https')
23
+ ? require('https')
24
+ : require('http');
25
+
26
+ var request = httpModule.request(
27
+ urlBase,
20
28
  {
29
+ method: 'POST',
21
30
  agent: false,
22
- headers: { accept: 'text/event-stream' },
31
+ headers: {
32
+ 'Content-Type': 'text/plain',
33
+ },
23
34
  },
24
35
  function (res) {
25
- response = res;
26
- response.on('error', errorHandler);
27
- if (!active && !import.meta.webpackHot) {
28
- console.log(
29
- 'Hot Module Replacement is not enabled. Waiting for process restart...',
36
+ pendingRequest = undefined;
37
+ if (res.statusCode < 200 || res.statusCode >= 300) {
38
+ var error = new Error(
39
+ 'Problem communicating active modules to the server: HTTP ' +
40
+ res.statusCode,
30
41
  );
42
+ errorHandlers.forEach(function (onError) {
43
+ onError(error);
44
+ });
45
+ }
46
+ // Consume response data to free up memory
47
+ res.resume();
48
+ if (hasPendingUpdate) {
49
+ hasPendingUpdate = false;
50
+ sendRequest();
31
51
  }
32
52
  },
33
53
  );
34
54
 
35
- /**
36
- * @param {Error} err error
37
- */
38
- function errorHandler(err) {
39
- err.message =
40
- 'Problem communicating active modules to the server' +
41
- (err.message ? ': ' + err.message : '') +
42
- '\nRequest: ' +
43
- urlBase +
44
- data;
45
- onError(err);
46
- }
47
- request.on('error', errorHandler);
55
+ pendingRequest = request;
56
+
57
+ request.on('error', function (err) {
58
+ pendingRequest = undefined;
59
+ var error = new Error(
60
+ 'Problem communicating active modules to the server: ' + err.message,
61
+ );
62
+ errorHandlers.forEach(function (onError) {
63
+ onError(error);
64
+ });
65
+ });
66
+
67
+ request.write(data);
48
68
  request.end();
69
+ }
70
+
71
+ function sendActiveRequest() {
72
+ hasPendingUpdate = true;
73
+
74
+ // If no request is pending, start one
75
+ if (!pendingRequest) {
76
+ hasPendingUpdate = false;
77
+ sendRequest();
78
+ }
79
+ }
80
+
81
+ /**
82
+ * @param {{ data: string, onError: (err: Error) => void, active: boolean, module: module }} options options
83
+ * @returns {() => void} function to destroy response
84
+ */
85
+ export const activate = function (options) {
86
+ var data = options.data;
87
+ var onError = options.onError;
88
+ var active = options.active;
89
+ var module = options.module;
90
+
91
+ errorHandlers.add(onError);
92
+
93
+ if (!compiling.has(data)) {
94
+ compiling.add(data);
95
+ sendActiveRequest();
96
+ }
97
+
98
+ if (!active && !module.hot) {
99
+ console.log(
100
+ 'Hot Module Replacement is not enabled. Waiting for process restart...',
101
+ );
102
+ }
103
+
49
104
  return function () {
50
- response.destroy();
105
+ errorHandlers.delete(onError);
106
+ compiling.delete(data);
107
+ sendActiveRequest();
51
108
  };
52
109
  };
@@ -1,47 +1,73 @@
1
- if (typeof EventSource !== 'function') {
1
+ if (typeof XMLHttpRequest === 'undefined') {
2
2
  throw new Error(
3
- "Environment doesn't support lazy compilation (requires EventSource)",
3
+ "Environment doesn't support lazy compilation (requires XMLHttpRequest)",
4
4
  );
5
5
  }
6
6
 
7
7
  var urlBase = decodeURIComponent(__resourceQuery.slice(1));
8
- /** @type {EventSource | undefined} */
9
- var activeEventSource;
10
8
  var compiling = new Set();
11
9
  var errorHandlers = new Set();
12
10
 
13
- var updateEventSource = function updateEventSource() {
14
- if (activeEventSource) activeEventSource.close();
15
- if (compiling.size) {
16
- activeEventSource = new EventSource(
17
- urlBase +
18
- Array.from(compiling, function (module) {
19
- return encodeURIComponent(module);
20
- }).join('@'),
21
- );
22
- /**
23
- * @this {EventSource}
24
- * @param {Event & { message?: string, filename?: string, lineno?: number, colno?: number, error?: Error }} event event
25
- */
26
- activeEventSource.onerror = function (event) {
27
- errorHandlers.forEach(function (onError) {
28
- onError(
29
- new Error(
30
- 'Problem communicating active modules to the server' +
31
- (event.message ? `: ${event.message} ` : '') +
32
- (event.filename ? `: ${event.filename} ` : '') +
33
- (event.lineno ? `: ${event.lineno} ` : '') +
34
- (event.colno ? `: ${event.colno} ` : '') +
35
- (event.error ? `: ${event.error}` : ''),
36
- ),
37
- );
38
- });
39
- };
40
- } else {
41
- activeEventSource = undefined;
11
+ /** @type {XMLHttpRequest | undefined} */
12
+ var pendingXhr;
13
+ /** @type {boolean} */
14
+ var hasPendingUpdate = false;
15
+
16
+ var sendRequest = function sendRequest() {
17
+ if (compiling.size === 0) {
18
+ hasPendingUpdate = false;
19
+ return;
42
20
  }
21
+
22
+ var modules = Array.from(compiling);
23
+ var data = modules.join('\n');
24
+
25
+ var xhr = new XMLHttpRequest();
26
+ pendingXhr = xhr;
27
+ xhr.open('POST', urlBase, true);
28
+ // text/plain Content-Type is simple request header
29
+ xhr.setRequestHeader('Content-Type', 'text/plain');
30
+
31
+ xhr.onreadystatechange = function () {
32
+ if (xhr.readyState === 4) {
33
+ pendingXhr = undefined;
34
+ if (xhr.status < 200 || xhr.status >= 300) {
35
+ var error = new Error(
36
+ 'Problem communicating active modules to the server: HTTP ' +
37
+ xhr.status,
38
+ );
39
+ errorHandlers.forEach(function (onError) {
40
+ onError(error);
41
+ });
42
+ }
43
+ if (hasPendingUpdate) {
44
+ hasPendingUpdate = false;
45
+ sendRequest();
46
+ }
47
+ }
48
+ };
49
+
50
+ xhr.onerror = function () {
51
+ pendingXhr = undefined;
52
+ var error = new Error('Problem communicating active modules to the server');
53
+ errorHandlers.forEach(function (onError) {
54
+ onError(error);
55
+ });
56
+ };
57
+
58
+ xhr.send(data);
43
59
  };
44
60
 
61
+ function sendActiveRequest() {
62
+ hasPendingUpdate = true;
63
+
64
+ // If no request is pending, start one
65
+ if (!pendingXhr) {
66
+ hasPendingUpdate = false;
67
+ sendRequest();
68
+ }
69
+ }
70
+
45
71
  /**
46
72
  * @param {{ data: string, onError: (err: Error) => void, active: boolean, module: module }} options options
47
73
  * @returns {() => void} function to destroy response
@@ -54,7 +80,7 @@ export const activate = function (options) {
54
80
 
55
81
  if (!compiling.has(data)) {
56
82
  compiling.add(data);
57
- updateEventSource();
83
+ sendActiveRequest();
58
84
  }
59
85
 
60
86
  if (!active && !import.meta.webpackHot) {
@@ -66,6 +92,6 @@ export const activate = function (options) {
66
92
  return function () {
67
93
  errorHandlers.delete(onError);
68
94
  compiling.delete(data);
69
- updateEventSource();
95
+ sendActiveRequest();
70
96
  };
71
97
  };
package/hot/log.js CHANGED
@@ -84,6 +84,4 @@ log.groupEnd = groupEnd;
84
84
  log.setLogLevel = setLogLevel;
85
85
  log.formatError = formatError;
86
86
 
87
- // TODO: remove default export when rspack-dev-server refactored
88
- export default log;
89
87
  export { log };
@@ -22,7 +22,7 @@ if (import.meta.webpackHot) {
22
22
  log('warning', '[HMR] Cannot find update. Need to do a full reload!');
23
23
  log(
24
24
  'warning',
25
- '[HMR] (Probably because of restarting the webpack-dev-server)',
25
+ '[HMR] (Probably because of restarting the rspack-dev-server)',
26
26
  );
27
27
  return;
28
28
  }
package/module.d.ts CHANGED
@@ -176,7 +176,10 @@ declare namespace Rspack {
176
176
  id: ModuleId;
177
177
  loaded: boolean;
178
178
  parents: NodeJS.Module['id'][] | null | undefined;
179
- children: NodeJS.Module['id'][];
179
+ // Keep `any[]` for compatibility:
180
+ // - Rspack runtime uses module ids
181
+ // - `@types/node` defines `children` as `Module[]`.
182
+ children: any[];
180
183
  hot?: Hot;
181
184
  }
182
185
 
@@ -210,7 +213,6 @@ declare namespace Rspack {
210
213
  interface Process {
211
214
  env: {
212
215
  [key: string]: any;
213
- NODE_ENV: 'development' | 'production' | (string & {});
214
216
  };
215
217
  }
216
218
  }
package/package.json CHANGED
@@ -1,9 +1,9 @@
1
1
  {
2
2
  "name": "@rspack-debug/core",
3
- "version": "2.0.0-canary-20260116",
3
+ "version": "2.0.0-rc.0",
4
4
  "webpackVersion": "5.75.0",
5
5
  "license": "MIT",
6
- "description": "The fast Rust-based web bundler with webpack-compatible API",
6
+ "description": "Fast Rust-based bundler for the web with a modernized webpack API",
7
7
  "types": "./dist/index.d.ts",
8
8
  "publishConfig": {
9
9
  "access": "public",
@@ -37,30 +37,32 @@
37
37
  "directory": "packages/rspack"
38
38
  },
39
39
  "devDependencies": {
40
- "@ast-grep/napi": "^0.40.4",
41
- "@napi-rs/wasm-runtime": "1.0.7",
42
- "@rsbuild/plugin-node-polyfill": "^1.4.2",
43
- "@rslib/core": "0.19.1",
44
- "@swc/types": "0.1.25",
45
- "@types/node": "^20.19.27",
40
+ "@ast-grep/napi": "^0.42.0",
41
+ "@napi-rs/wasm-runtime": "1.1.2",
42
+ "@rsbuild/plugin-node-polyfill": "^1.4.4",
43
+ "@rslib/core": "0.20.2",
44
+ "@rspack/lite-tapable": "1.1.0",
45
+ "@swc/types": "0.1.26",
46
+ "@types/node": "^20.19.37",
46
47
  "@types/watchpack": "^2.4.5",
47
48
  "browserslist-load-config": "^1.0.1",
48
- "enhanced-resolve": "5.18.4",
49
- "glob-to-regexp": "^0.4.1",
50
- "memfs": "4.51.1",
51
- "prebundle": "^1.6.0",
49
+ "browserslist-to-es-version": "^1.4.1",
50
+ "connect-next": "^4.0.0",
51
+ "enhanced-resolve": "5.20.1",
52
+ "http-proxy-middleware": "^3.0.5",
53
+ "memfs": "4.53.0",
54
+ "open": "^11.0.0",
55
+ "prebundle": "^1.6.4",
52
56
  "tinypool": "^1.1.1",
53
- "tsx": "^4.21.0",
54
- "typescript": "^5.9.3",
55
- "watchpack": "^2.4.4",
56
- "webpack-sources": "3.3.3"
57
+ "typescript": "^6.0.2",
58
+ "watchpack": "2.4.4",
59
+ "webpack-sources": "3.3.4"
57
60
  },
58
61
  "dependencies": {
59
- "@rspack/lite-tapable": "1.1.0",
60
- "@rspack/binding": "npm:@rspack-debug/binding@2.0.0-canary-20260116"
62
+ "@rspack/binding": "npm:@rspack-debug/binding@2.0.0-rc.0"
61
63
  },
62
64
  "peerDependencies": {
63
- "@module-federation/runtime-tools": ">=0.22.0",
65
+ "@module-federation/runtime-tools": "^0.24.1 || ^2.0.0",
64
66
  "@swc/helpers": ">=0.5.1"
65
67
  },
66
68
  "peerDependenciesMeta": {
@@ -73,10 +75,7 @@
73
75
  },
74
76
  "scripts": {
75
77
  "build": "rslib build",
76
- "build:browser": "rslib build -c rslib.browser.config.mts",
77
- "dev": "rslib build --watch",
78
- "doc-coverage": "tsx ./scripts/check-documentation-coverage.ts",
79
- "api-extractor": "api-extractor run --verbose",
80
- "api-extractor:ci": "api-extractor run --verbose || diff temp/core.api.md etc/core.api.md"
78
+ "build:browser": "rslib build -c rslib.browser.config.ts",
79
+ "dev": "rslib build --watch"
81
80
  }
82
81
  }
@@ -1,21 +0,0 @@
1
- declare function findConfig(from: string): Record<string, string[]> | undefined;
2
- type LoadConfigOptions = {
3
- /**
4
- * Specify the path to the configuration file
5
- * If both `config` and `path` are provided, `config` will be used
6
- */
7
- config?: string;
8
- /**
9
- * Specify the directory where the configuration file is located
10
- */
11
- path?: string;
12
- /**
13
- * Specify the environment to load
14
- * @default "production"
15
- */
16
- env?: string;
17
- };
18
- declare function loadConfig(opts: LoadConfigOptions): string[] | undefined;
19
-
20
- export { findConfig, loadConfig };
21
- export type { LoadConfigOptions };
@@ -1,252 +0,0 @@
1
- /******/ (() => { // webpackBootstrap
2
- /******/ "use strict";
3
- /******/ var __webpack_modules__ = ({
4
-
5
- /***/ 24:
6
- /***/ ((module) => {
7
-
8
- module.exports = require("node:fs");
9
-
10
- /***/ }),
11
-
12
- /***/ 760:
13
- /***/ ((module) => {
14
-
15
- module.exports = require("node:path");
16
-
17
- /***/ }),
18
-
19
- /***/ 867:
20
- /***/ ((__unused_webpack_module, exports, __nccwpck_require__) => {
21
-
22
-
23
- var __nested_webpack_require_18__ = {};
24
- (()=>{
25
- __nested_webpack_require_18__.n = (module)=>{
26
- var getter = module && module.__esModule ? ()=>module['default'] : ()=>module;
27
- __nested_webpack_require_18__.d(getter, {
28
- a: getter
29
- });
30
- return getter;
31
- };
32
- })();
33
- (()=>{
34
- __nested_webpack_require_18__.d = (exports1, definition)=>{
35
- for(var key in definition)if (__nested_webpack_require_18__.o(definition, key) && !__nested_webpack_require_18__.o(exports1, key)) Object.defineProperty(exports1, key, {
36
- enumerable: true,
37
- get: definition[key]
38
- });
39
- };
40
- })();
41
- (()=>{
42
- __nested_webpack_require_18__.o = (obj, prop)=>Object.prototype.hasOwnProperty.call(obj, prop);
43
- })();
44
- (()=>{
45
- __nested_webpack_require_18__.r = (exports1)=>{
46
- if ('undefined' != typeof Symbol && Symbol.toStringTag) Object.defineProperty(exports1, Symbol.toStringTag, {
47
- value: 'Module'
48
- });
49
- Object.defineProperty(exports1, '__esModule', {
50
- value: true
51
- });
52
- };
53
- })();
54
- var __nested_webpack_exports__ = {};
55
- __nested_webpack_require_18__.r(__nested_webpack_exports__);
56
- __nested_webpack_require_18__.d(__nested_webpack_exports__, {
57
- loadConfig: ()=>loadConfig,
58
- findConfig: ()=>findConfig
59
- });
60
- const external_node_fs_namespaceObject = __nccwpck_require__(24);
61
- var external_node_fs_default = /*#__PURE__*/ __nested_webpack_require_18__.n(external_node_fs_namespaceObject);
62
- const external_node_path_namespaceObject = __nccwpck_require__(760);
63
- var external_node_path_default = /*#__PURE__*/ __nested_webpack_require_18__.n(external_node_path_namespaceObject);
64
- function _define_property(obj, key, value) {
65
- if (key in obj) Object.defineProperty(obj, key, {
66
- value: value,
67
- enumerable: true,
68
- configurable: true,
69
- writable: true
70
- });
71
- else obj[key] = value;
72
- return obj;
73
- }
74
- class BrowserslistError extends Error {
75
- constructor(message){
76
- super(message), _define_property(this, "browserslist", void 0);
77
- this.name = 'BrowserslistError';
78
- this.browserslist = true;
79
- if (Error.captureStackTrace) Error.captureStackTrace(this, BrowserslistError);
80
- }
81
- }
82
- const isFileCache = {};
83
- function isFile(file) {
84
- if (file in isFileCache) return isFileCache[file];
85
- const result = external_node_fs_default().existsSync(file) && external_node_fs_default().statSync(file).isFile();
86
- isFileCache[file] = result;
87
- return result;
88
- }
89
- function check(section) {
90
- const FORMAT = 'Browserslist config should be a string or an array of strings with browser queries';
91
- if (Array.isArray(section)) {
92
- for(let i = 0; i < section.length; i++)if ('string' != typeof section[i]) throw new BrowserslistError(FORMAT);
93
- } else if ('string' != typeof section) throw new BrowserslistError(FORMAT);
94
- }
95
- function parsePackage(file) {
96
- const config = JSON.parse(external_node_fs_default().readFileSync(file).toString().replace(/^\uFEFF/m, ''));
97
- if (config.browserlist && !config.browserslist) throw new BrowserslistError(`\`browserlist\` key instead of \`browserslist\` in ${file}`);
98
- let list = config.browserslist;
99
- if (Array.isArray(list)) list = {
100
- defaults: list
101
- };
102
- if ('string' == typeof list) list = parseConfig(list);
103
- for(const i in list)check(list[i]);
104
- return list;
105
- }
106
- const IS_SECTION = /^\s*\[(.+)]\s*$/;
107
- function parseConfig(string) {
108
- const result = {
109
- defaults: []
110
- };
111
- let sections = [
112
- 'defaults'
113
- ];
114
- string.toString().replace(/#[^\n]*/g, '').split(/\n|,/).map((line)=>line.trim()).filter((line)=>'' !== line).forEach((line)=>{
115
- const matched = line.match(IS_SECTION);
116
- if (matched) {
117
- sections = matched[1].trim().split(' ');
118
- sections.forEach((section)=>{
119
- if (result[section]) throw new BrowserslistError(`Duplicate section ${section} in Browserslist config`);
120
- result[section] = [];
121
- });
122
- } else sections.forEach((section)=>{
123
- result[section].push(line);
124
- });
125
- });
126
- return result;
127
- }
128
- function readConfig(file) {
129
- if (!isFile(file)) throw new BrowserslistError(`Can't read ${file} config`);
130
- return parseConfig(external_node_fs_default().readFileSync(file, 'utf-8'));
131
- }
132
- function parsePackageOrReadConfig(file) {
133
- if ('package.json' === external_node_path_default().basename(file)) return parsePackage(file);
134
- return readConfig(file);
135
- }
136
- function pickEnv(config, opts) {
137
- if ('object' != typeof config) return config;
138
- let name;
139
- name = 'string' == typeof opts.env ? opts.env : process.env.BROWSERSLIST_ENV ? process.env.BROWSERSLIST_ENV : process.env.NODE_ENV ? process.env.NODE_ENV : 'production';
140
- return config[name] || config.defaults;
141
- }
142
- function eachParent(file, callback) {
143
- const dir = isFile(file) ? external_node_path_default().dirname(file) : file;
144
- let loc = external_node_path_default().resolve(dir);
145
- do {
146
- const result = callback(loc);
147
- if (void 0 !== result) return result;
148
- }while (loc !== (loc = external_node_path_default().dirname(loc)));
149
- }
150
- function findConfigFile(from) {
151
- return eachParent(from, (dir)=>{
152
- const config = external_node_path_default().join(dir, 'browserslist');
153
- const pkg = external_node_path_default().join(dir, 'package.json');
154
- const rc = external_node_path_default().join(dir, '.browserslistrc');
155
- let pkgBrowserslist;
156
- if (isFile(pkg)) try {
157
- pkgBrowserslist = parsePackage(pkg);
158
- } catch (e) {
159
- if (e instanceof BrowserslistError) throw e;
160
- console.warn(`[Browserslist] Could not parse ${pkg}. Ignoring it.`);
161
- }
162
- if (isFile(config) && pkgBrowserslist) throw new BrowserslistError(`${dir} contains both browserslist and package.json with browsers`);
163
- if (isFile(rc) && pkgBrowserslist) throw new BrowserslistError(`${dir} contains both .browserslistrc and package.json with browsers`);
164
- if (isFile(config) && isFile(rc)) throw new BrowserslistError(`${dir} contains both .browserslistrc and browserslist`);
165
- if (isFile(config)) return config;
166
- if (isFile(rc)) return rc;
167
- if (pkgBrowserslist) return pkg;
168
- });
169
- }
170
- const configCache = {};
171
- function findConfig(from) {
172
- from = external_node_path_default().resolve(from);
173
- const fromDir = isFile(from) ? external_node_path_default().dirname(from) : from;
174
- if (fromDir in configCache) return configCache[fromDir];
175
- let resolved;
176
- const configFile = findConfigFile(from);
177
- if (configFile) resolved = parsePackageOrReadConfig(configFile);
178
- const configDir = configFile && external_node_path_default().dirname(configFile);
179
- eachParent(from, (dir)=>{
180
- if (resolved) configCache[dir] = resolved;
181
- if (dir === configDir) return null;
182
- });
183
- return resolved;
184
- }
185
- function loadConfig(opts) {
186
- if (opts.config) return pickEnv(parsePackageOrReadConfig(opts.config), opts);
187
- if (opts.path) {
188
- const config = findConfig(opts.path);
189
- if (!config) return;
190
- return pickEnv(config, opts);
191
- }
192
- }
193
- exports.findConfig = __nested_webpack_exports__.findConfig;
194
- exports.loadConfig = __nested_webpack_exports__.loadConfig;
195
- for(var __webpack_i__ in __nested_webpack_exports__)if (-1 === [
196
- "findConfig",
197
- "loadConfig"
198
- ].indexOf(__webpack_i__)) exports[__webpack_i__] = __nested_webpack_exports__[__webpack_i__];
199
- Object.defineProperty(exports, "__esModule", ({
200
- value: true
201
- }));
202
-
203
-
204
- /***/ })
205
-
206
- /******/ });
207
- /************************************************************************/
208
- /******/ // The module cache
209
- /******/ var __webpack_module_cache__ = {};
210
- /******/
211
- /******/ // The require function
212
- /******/ function __nccwpck_require__(moduleId) {
213
- /******/ // Check if module is in cache
214
- /******/ var cachedModule = __webpack_module_cache__[moduleId];
215
- /******/ if (cachedModule !== undefined) {
216
- /******/ return cachedModule.exports;
217
- /******/ }
218
- /******/ // Create a new module (and put it into the cache)
219
- /******/ var module = __webpack_module_cache__[moduleId] = {
220
- /******/ // no module.id needed
221
- /******/ // no module.loaded needed
222
- /******/ exports: {}
223
- /******/ };
224
- /******/
225
- /******/ // Execute the module function
226
- /******/ var threw = true;
227
- /******/ try {
228
- /******/ __webpack_modules__[moduleId](module, module.exports, __nccwpck_require__);
229
- /******/ threw = false;
230
- /******/ } finally {
231
- /******/ if(threw) delete __webpack_module_cache__[moduleId];
232
- /******/ }
233
- /******/
234
- /******/ // Return the exports of the module
235
- /******/ return module.exports;
236
- /******/ }
237
- /******/
238
- /************************************************************************/
239
- /******/ /* webpack/runtime/compat */
240
- /******/
241
- /******/ if (typeof __nccwpck_require__ !== 'undefined') __nccwpck_require__.ab = __dirname + "/";
242
- /******/
243
- /************************************************************************/
244
- /******/
245
- /******/ // startup
246
- /******/ // Load entry module and return exports
247
- /******/ // This entry module is referenced by other modules so it can't be inlined
248
- /******/ var __webpack_exports__ = __nccwpck_require__(867);
249
- /******/ module.exports = __webpack_exports__;
250
- /******/
251
- /******/ })()
252
- ;
@@ -1 +0,0 @@
1
- {"name":"browserslist-load-config","version":"1.0.1","license":"MIT","types":"index.d.ts","type":"commonjs"}
@@ -1 +0,0 @@
1
- export * from './swc/index.js';