diff --git a/.github/CODEOWNERS b/.github/CODEOWNERS index 4bfcf40ea47..8bd0cc204c6 100644 --- a/.github/CODEOWNERS +++ b/.github/CODEOWNERS @@ -49,7 +49,6 @@ pnpm-lock.yaml # Loaders -/crates/rspack_loader_sass @web-infra-dev/rspack-dx /crates/rspack_loader_swc @web-infra-dev/rspack-dx # Plugins @@ -58,7 +57,6 @@ pnpm-lock.yaml /crates/rspack_plugin_banner @web-infra-dev/rspack-dx /crates/rspack_plugin_copy @web-infra-dev/rspack-dx /crates/rspack_plugin_css @web-infra-dev/rspack-ux -/crates/rspack_plugin_dev_friendly_split_chunks @web-infra-dev/rspack-ux /crates/rspack_plugin_devtool @web-infra-dev/rspack-dx /crates/rspack_plugin_entry @web-infra-dev/rspack-dx /crates/rspack_plugin_externals @web-infra-dev/rspack-dx diff --git a/Cargo.lock b/Cargo.lock index e8442a989ac..ce122a06f35 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -355,12 +355,6 @@ version = "1.4.3" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "14c189c53d098945499cdfa7ecc63567cf3886b3332b312a5b4585d8d3a6a610" -[[package]] -name = "bytes" -version = "1.4.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "89b2fd2a0dcf38d7971e2194b6b6eebab45ae01067456a7fd93d5547a61b70be" - [[package]] name = "cargo-rst" version = "0.1.0" @@ -609,12 +603,6 @@ version = "0.2.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "b365fabc795046672053e29c954733ec3b05e4be654ab130fe8f1f94d7051f35" -[[package]] -name = "daachorse" -version = "1.0.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "63b7ef7a4be509357f4804d0a22e830daddb48f19fd604e4ad32ddce04a94c36" - [[package]] name = "darling" version = "0.14.4" @@ -1607,26 +1595,6 @@ version = "1.0.4" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "e4a24736216ec316047a1fc4252e27dabb04218aa4a3f37c6e7ddbf1f9782b54" -[[package]] -name = "nodejs-resolver" -version = "0.1.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "517c9a4e74fdd7a26d38b1dca0cfff40af33ee3b1d5f379f7c9d711ba5a5d10d" -dependencies = [ - "daachorse", - "dashmap", - "dunce", - "indexmap 2.1.0", - "jsonc-parser 0.22.1", - "once_cell", - "path-absolutize", - "rustc-hash", - "serde", - "serde_json", - "tracing", - "tracing-subscriber", -] - [[package]] name = "nom" version = "7.1.3" @@ -1813,15 +1781,6 @@ version = "1.0.13" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "b4b27ab7be369122c218afc2079489cdcb4b517c0a3fc386ff11e1fedfcc2b35" -[[package]] -name = "path-absolutize" -version = "3.1.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "43eb3595c63a214e1b37b44f44b0a84900ef7ae0b4c5efce59e123d246d7a0de" -dependencies = [ - "path-dedot", -] - [[package]] name = "path-clean" version = "0.1.0" @@ -1834,15 +1793,6 @@ version = "1.0.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "17359afc20d7ab31fdb42bb844c8b3bb1dabd7dcf7e68428492da7f16966fcef" -[[package]] -name = "path-dedot" -version = "3.1.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9d55e486337acb9973cdea3ec5638c1b3bcb22e573b2b7b41969e0c744d5a15e" -dependencies = [ - "once_cell", -] - [[package]] name = "pathdiff" version = "0.2.1" @@ -2122,29 +2072,6 @@ dependencies = [ "unicode-ident", ] -[[package]] -name = "prost" -version = "0.11.9" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0b82eaa1d779e9a4bc1c3217db8ffbeabaae1dca241bf70183242128d48681cd" -dependencies = [ - "bytes", - "prost-derive", -] - -[[package]] -name = "prost-derive" -version = "0.11.9" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e5d2d8d10f3c6ded6da8b05b5fb3b8a5082514344d56c9f871412d29b4e075b4" -dependencies = [ - "anyhow", - "itertools", - "proc-macro2", - "quote", - "syn 1.0.109", -] - [[package]] name = "psm" version = "0.1.21" @@ -2451,14 +2378,12 @@ dependencies = [ "rspack_ids", "rspack_loader_react_refresh", "rspack_loader_runner", - "rspack_loader_sass", "rspack_loader_swc", "rspack_napi_shared", "rspack_plugin_asset", "rspack_plugin_banner", "rspack_plugin_copy", "rspack_plugin_css", - "rspack_plugin_dev_friendly_split_chunks", "rspack_plugin_devtool", "rspack_plugin_ensure_chunk_conditions", "rspack_plugin_entry", @@ -2476,7 +2401,6 @@ dependencies = [ "rspack_plugin_remove_empty_chunks", "rspack_plugin_runtime", "rspack_plugin_schemes", - "rspack_plugin_split_chunks", "rspack_plugin_split_chunks_new", "rspack_plugin_swc_css_minimizer", "rspack_plugin_swc_js_minimizer", @@ -2516,14 +2440,12 @@ dependencies = [ "rspack_ids", "rspack_loader_react_refresh", "rspack_loader_runner", - "rspack_loader_sass", "rspack_loader_swc", "rspack_napi_shared", "rspack_plugin_asset", "rspack_plugin_banner", "rspack_plugin_copy", "rspack_plugin_css", - "rspack_plugin_dev_friendly_split_chunks", "rspack_plugin_devtool", "rspack_plugin_ensure_chunk_conditions", "rspack_plugin_entry", @@ -2538,7 +2460,6 @@ dependencies = [ "rspack_plugin_remove_empty_chunks", "rspack_plugin_runtime", "rspack_plugin_schemes", - "rspack_plugin_split_chunks", "rspack_plugin_split_chunks_new", "rspack_plugin_swc_css_minimizer", "rspack_plugin_swc_js_minimizer", @@ -2575,7 +2496,6 @@ dependencies = [ "itertools", "json", "mime_guess", - "nodejs-resolver", "once_cell", "oxc_resolver", "paste", @@ -2731,25 +2651,6 @@ dependencies = [ "tokio", ] -[[package]] -name = "rspack_loader_sass" -version = "0.1.0" -dependencies = [ - "async-trait", - "indexmap 1.9.3", - "itertools", - "once_cell", - "regex", - "rspack_core", - "rspack_error", - "rspack_loader_runner", - "rspack_testing", - "sass-embedded", - "serde", - "str_indices", - "tokio", -] - [[package]] name = "rspack_loader_swc" version = "0.1.0" @@ -2900,17 +2801,6 @@ dependencies = [ "urlencoding", ] -[[package]] -name = "rspack_plugin_dev_friendly_split_chunks" -version = "0.1.0" -dependencies = [ - "async-trait", - "dashmap", - "rayon", - "rspack_core", - "rspack_identifier", -] - [[package]] name = "rspack_plugin_devtool" version = "0.1.0" @@ -3167,19 +3057,6 @@ dependencies = [ "urlencoding", ] -[[package]] -name = "rspack_plugin_split_chunks" -version = "0.1.0" -dependencies = [ - "async-trait", - "derivative", - "rspack_core", - "rspack_identifier", - "rspack_util", - "rustc-hash", - "tracing", -] - [[package]] name = "rspack_plugin_split_chunks_new" version = "0.1.0" @@ -3335,11 +3212,9 @@ dependencies = [ "rspack_fs", "rspack_ids", "rspack_loader_runner", - "rspack_loader_sass", "rspack_loader_swc", "rspack_plugin_asset", "rspack_plugin_css", - "rspack_plugin_dev_friendly_split_chunks", "rspack_plugin_devtool", "rspack_plugin_entry", "rspack_plugin_externals", @@ -3444,25 +3319,6 @@ dependencies = [ "winapi-util", ] -[[package]] -name = "sass-embedded" -version = "0.7.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "043fea16ac00f7132b50dce6094873fee0d328bd43c0f552faeb33d989d97b77" -dependencies = [ - "atty", - "crossbeam-channel", - "dashmap", - "parking_lot 0.12.1", - "prost", - "regex", - "rustc-hash", - "serde", - "serde_json", - "url", - "urlencoding", -] - [[package]] name = "schemars" version = "0.8.12" @@ -5497,7 +5353,6 @@ dependencies = [ "form_urlencoded", "idna", "percent-encoding", - "serde", ] [[package]] diff --git a/crates/node_binding/binding.d.ts b/crates/node_binding/binding.d.ts index 61978f3b8dc..321d849541f 100644 --- a/crates/node_binding/binding.d.ts +++ b/crates/node_binding/binding.d.ts @@ -160,7 +160,6 @@ export const enum BuiltinPluginName { WebWorkerTemplatePlugin = 'WebWorkerTemplatePlugin', MergeDuplicateChunksPlugin = 'MergeDuplicateChunksPlugin', SplitChunksPlugin = 'SplitChunksPlugin', - OldSplitChunksPlugin = 'OldSplitChunksPlugin', ShareRuntimePlugin = 'ShareRuntimePlugin', ContainerPlugin = 'ContainerPlugin', ContainerReferencePlugin = 'ContainerReferencePlugin', @@ -620,15 +619,7 @@ export interface RawBannerPluginOptions { export interface RawBuiltins { css?: RawCssPluginConfig - presetEnv?: RawPresetEnv treeShaking: string - react: RawReactOptions - decorator?: RawDecoratorOptions - noEmitAssets: boolean - emotion?: string - devFriendlySplitChunks: boolean - pluginImport?: Array - relay?: RawRelayConfig } export interface RawCacheGroupOptions { @@ -744,15 +735,6 @@ export interface RawCssPluginConfig { modules: RawCssModulesConfig } -export interface RawDecoratorOptions { - legacy: boolean - emitMetadata: boolean -} - -export interface RawDevServer { - hot: boolean -} - export interface RawEntryOptions { name?: string runtime?: string @@ -771,7 +753,6 @@ export interface RawEntryPluginOptions { } export interface RawExperiments { - incrementalRebuild: RawIncrementalRebuild newSplitChunks: boolean topLevelAwait: boolean rspackFuture: RawRspackFuture @@ -864,11 +845,6 @@ export interface RawHttpExternalsRspackPluginOptions { webAsync: boolean } -export interface RawIncrementalRebuild { - make: boolean - emitAsset: boolean -} - export interface RawInfo { immutable?: boolean minimized?: boolean @@ -1008,7 +984,6 @@ export interface RawOptions { devtool: string optimization: RawOptimizationOptions stats: RawStatsOptions - devServer: RawDevServer snapshot: RawSnapshotOptions cache: RawCacheOptions experiments: RawExperiments @@ -1076,12 +1051,6 @@ export interface RawPluginImportConfig { ignoreStyleComponent?: Array } -export interface RawPresetEnv { - targets: Array - mode?: 'usage' | 'entry' - coreJs?: string -} - export interface RawProgressPluginOptions { prefix: string profile: boolean @@ -1152,9 +1121,7 @@ export interface RawResolveTsconfigOptions { } export interface RawRspackFuture { - newResolver: boolean newTreeshaking: boolean - disableTransformByDefault: boolean } export interface RawRuleSetCondition { diff --git a/crates/node_binding/package.json b/crates/node_binding/package.json index ed6b2563400..db3d821435e 100644 --- a/crates/node_binding/package.json +++ b/crates/node_binding/package.json @@ -1,6 +1,6 @@ { "name": "@rspack/binding", - "version": "0.4.5", + "version": "0.5.0", "license": "MIT", "description": "Node binding for rspack", "main": "binding.js", diff --git a/crates/rspack/tests/fixtures/simple-with-query/b.js b/crates/rspack/tests/fixtures/simple-with-query/b.js deleted file mode 100644 index 84c67edefbd..00000000000 --- a/crates/rspack/tests/fixtures/simple-with-query/b.js +++ /dev/null @@ -1 +0,0 @@ -export const a = 3; diff --git a/crates/rspack/tests/fixtures/simple-with-query/b.jsx b/crates/rspack/tests/fixtures/simple-with-query/b.jsx deleted file mode 100644 index 84c67edefbd..00000000000 --- a/crates/rspack/tests/fixtures/simple-with-query/b.jsx +++ /dev/null @@ -1 +0,0 @@ -export const a = 3; diff --git a/crates/rspack/tests/fixtures/simple-with-query/index.js b/crates/rspack/tests/fixtures/simple-with-query/index.js deleted file mode 100644 index d87104e4377..00000000000 --- a/crates/rspack/tests/fixtures/simple-with-query/index.js +++ /dev/null @@ -1,5 +0,0 @@ -import { a as b } from "./b.jsx"; -import { a } from "./b.js?x"; -a; -b; -console.log("hello, world"); diff --git a/crates/rspack/tests/fixtures/simple-with-query/snapshot/output.snap b/crates/rspack/tests/fixtures/simple-with-query/snapshot/output.snap deleted file mode 100644 index e81b0e9e81a..00000000000 --- a/crates/rspack/tests/fixtures/simple-with-query/snapshot/output.snap +++ /dev/null @@ -1,40 +0,0 @@ ---- -source: crates/rspack_testing/src/run_fixture.rs ---- -```js title=main.js -(self['webpackChunkwebpack'] = self['webpackChunkwebpack'] || []).push([["main"], { -"./b.js?x": (function (__unused_webpack_module, __webpack_exports__, __webpack_require__) { -"use strict"; -__webpack_require__.r(__webpack_exports__); -__webpack_require__.d(__webpack_exports__, { - a: function() { return a; } -}); - const a = 3; -}), -"./index.js": (function (__unused_webpack_module, __webpack_exports__, __webpack_require__) { -"use strict"; -__webpack_require__.r(__webpack_exports__); -/* harmony import */var _b_jsx__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./b.jsx */"./b.jsx"); -/* harmony import */var _b_js_x__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./b.js?x */"./b.js?x"); - - -_b_js_x__WEBPACK_IMPORTED_MODULE_1__.a; -_b_jsx__WEBPACK_IMPORTED_MODULE_0__.a; -console.log("hello, world"); -}), -"./b.jsx": (function (__unused_webpack_module, __webpack_exports__, __webpack_require__) { -"use strict"; -__webpack_require__.r(__webpack_exports__); -__webpack_require__.d(__webpack_exports__, { - a: function() { return a; } -}); - const a = 3; -}), - -},function(__webpack_require__) { -var __webpack_exec__ = function(moduleId) { return __webpack_require__(__webpack_require__.s = moduleId) } -var __webpack_exports__ = (__webpack_exec__("./index.js")); - -} -]); -``` diff --git a/crates/rspack/tests/tree-shaking/cjs-export-computed-property/antd/index.ts b/crates/rspack/tests/tree-shaking/cjs-export-computed-property/antd/index.js similarity index 100% rename from crates/rspack/tests/tree-shaking/cjs-export-computed-property/antd/index.ts rename to crates/rspack/tests/tree-shaking/cjs-export-computed-property/antd/index.js diff --git a/crates/rspack/tests/tree-shaking/cjs-export-computed-property/index.ts b/crates/rspack/tests/tree-shaking/cjs-export-computed-property/index.js similarity index 100% rename from crates/rspack/tests/tree-shaking/cjs-export-computed-property/index.ts rename to crates/rspack/tests/tree-shaking/cjs-export-computed-property/index.js diff --git a/crates/rspack/tests/tree-shaking/cjs-export-computed-property/locale_zh.ts b/crates/rspack/tests/tree-shaking/cjs-export-computed-property/locale_zh.js similarity index 100% rename from crates/rspack/tests/tree-shaking/cjs-export-computed-property/locale_zh.ts rename to crates/rspack/tests/tree-shaking/cjs-export-computed-property/locale_zh.js diff --git a/crates/rspack/tests/tree-shaking/cjs-export-computed-property/snapshot/new_treeshaking.snap b/crates/rspack/tests/tree-shaking/cjs-export-computed-property/snapshot/new_treeshaking.snap index dff70ef8739..66830354334 100644 --- a/crates/rspack/tests/tree-shaking/cjs-export-computed-property/snapshot/new_treeshaking.snap +++ b/crates/rspack/tests/tree-shaking/cjs-export-computed-property/snapshot/new_treeshaking.snap @@ -3,38 +3,28 @@ source: crates/rspack_testing/src/run_fixture.rs --- ```js title=main.js (self['webpackChunkwebpack'] = self['webpackChunkwebpack'] || []).push([["main"], { -"./zh_locale.js": (function (__unused_webpack_module, exports) { -var __webpack_unused_export__; -"use strict"; -__webpack_unused_export__ = ({ - value: true -}); -exports["default"] = void 0; -/* eslint-disable no-template-curly-in-string */ var _default = {}; -exports["default"] = _default; -}), -"./antd/index.ts": (function (__unused_webpack_module, __webpack_exports__, __webpack_require__) { +"./antd/index.js": (function (__unused_webpack_module, __webpack_exports__, __webpack_require__) { "use strict"; __webpack_require__.r(__webpack_exports__); __webpack_require__.d(__webpack_exports__, { locales: function() { return locales; } }); -/* harmony import */var _locale_zh__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../locale_zh */"./locale_zh.ts"); +/* harmony import */var _locale_zh__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../locale_zh */"./locale_zh.js"); const locales = { zh_CN: _locale_zh__WEBPACK_IMPORTED_MODULE_0__["default"] }; }), -"./index.ts": (function (__unused_webpack_module, __webpack_exports__, __webpack_require__) { +"./index.js": (function (__unused_webpack_module, __webpack_exports__, __webpack_require__) { "use strict"; __webpack_require__.r(__webpack_exports__); -/* harmony import */var _antd_index__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./antd/index */"./antd/index.ts"); +/* harmony import */var _antd_index__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./antd/index */"./antd/index.js"); _antd_index__WEBPACK_IMPORTED_MODULE_0__.locales.zh_CN; function test() {} }), -"./locale_zh.ts": (function (__unused_webpack_module, __webpack_exports__, __webpack_require__) { +"./locale_zh.js": (function (__unused_webpack_module, __webpack_exports__, __webpack_require__) { "use strict"; __webpack_require__.r(__webpack_exports__); __webpack_require__.d(__webpack_exports__, { @@ -44,10 +34,20 @@ __webpack_require__.d(__webpack_exports__, { var __WEBPACK_DEFAULT_EXPORT__ = _zh_locale__WEBPACK_IMPORTED_MODULE_0__["default"]; }), +"./zh_locale.js": (function (__unused_webpack_module, exports) { +var __webpack_unused_export__; +"use strict"; +__webpack_unused_export__ = ({ + value: true +}); +exports["default"] = void 0; +/* eslint-disable no-template-curly-in-string */ var _default = {}; +exports["default"] = _default; +}), },function(__webpack_require__) { var __webpack_exec__ = function(moduleId) { return __webpack_require__(__webpack_require__.s = moduleId) } -var __webpack_exports__ = (__webpack_exec__("./index.ts")); +var __webpack_exports__ = (__webpack_exec__("./index.js")); } ]); diff --git a/crates/rspack/tests/tree-shaking/cjs-export-computed-property/snapshot/output.snap b/crates/rspack/tests/tree-shaking/cjs-export-computed-property/snapshot/output.snap index 8f53dd416ef..c9566710442 100644 --- a/crates/rspack/tests/tree-shaking/cjs-export-computed-property/snapshot/output.snap +++ b/crates/rspack/tests/tree-shaking/cjs-export-computed-property/snapshot/output.snap @@ -3,40 +3,31 @@ source: crates/rspack_testing/src/run_fixture.rs --- ```js title=main.js (self['webpackChunkwebpack'] = self['webpackChunkwebpack'] || []).push([["main"], { -"./zh_locale.js": (function (__unused_webpack_module, exports) { -"use strict"; -Object.defineProperty(exports, "__esModule", ({ - value: true -})); -exports["default"] = void 0; -/* eslint-disable no-template-curly-in-string */ var _default = {}; -exports["default"] = _default; -}), -"./antd/index.ts": (function (__unused_webpack_module, __webpack_exports__, __webpack_require__) { +"./antd/index.js": (function (__unused_webpack_module, __webpack_exports__, __webpack_require__) { "use strict"; __webpack_require__.r(__webpack_exports__); __webpack_require__.d(__webpack_exports__, { locales: function() { return locales; } }); -/* harmony import */var _locale_zh__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../locale_zh */"./locale_zh.ts"); +/* harmony import */var _locale_zh__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../locale_zh */"./locale_zh.js"); const locales = { zh_CN: _locale_zh__WEBPACK_IMPORTED_MODULE_0__["default"] }; }), -"./index.ts": (function (__unused_webpack_module, __webpack_exports__, __webpack_require__) { +"./index.js": (function (__unused_webpack_module, __webpack_exports__, __webpack_require__) { "use strict"; __webpack_require__.r(__webpack_exports__); __webpack_require__.d(__webpack_exports__, { test: function() { return test; } }); -/* harmony import */var _antd_index__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./antd/index */"./antd/index.ts"); +/* harmony import */var _antd_index__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./antd/index */"./antd/index.js"); _antd_index__WEBPACK_IMPORTED_MODULE_0__.locales.zh_CN; function test() {} }), -"./locale_zh.ts": (function (__unused_webpack_module, __webpack_exports__, __webpack_require__) { +"./locale_zh.js": (function (__unused_webpack_module, __webpack_exports__, __webpack_require__) { "use strict"; __webpack_require__.r(__webpack_exports__); __webpack_require__.d(__webpack_exports__, { @@ -46,10 +37,19 @@ __webpack_require__.d(__webpack_exports__, { var __WEBPACK_DEFAULT_EXPORT__ = _zh_locale__WEBPACK_IMPORTED_MODULE_0__["default"]; }), +"./zh_locale.js": (function (__unused_webpack_module, exports) { +"use strict"; +Object.defineProperty(exports, "__esModule", ({ + value: true +})); +exports["default"] = void 0; +/* eslint-disable no-template-curly-in-string */ var _default = {}; +exports["default"] = _default; +}), },function(__webpack_require__) { var __webpack_exec__ = function(moduleId) { return __webpack_require__(__webpack_require__.s = moduleId) } -var __webpack_exports__ = (__webpack_exec__("./index.ts")); +var __webpack_exports__ = (__webpack_exec__("./index.js")); } ]); diff --git a/crates/rspack/tests/tree-shaking/cjs-export-computed-property/snapshot/snap.diff b/crates/rspack/tests/tree-shaking/cjs-export-computed-property/snapshot/snap.diff index a3710b30348..3af88994c77 100644 --- a/crates/rspack/tests/tree-shaking/cjs-export-computed-property/snapshot/snap.diff +++ b/crates/rspack/tests/tree-shaking/cjs-export-computed-property/snapshot/snap.diff @@ -1,8 +1,18 @@ --- expected +++ actual -@@ -4,10 +4,11 @@ - ```js title=main.js - (self['webpackChunkwebpack'] = self['webpackChunkwebpack'] || []).push([["main"], { +@@ -19,9 +19,6 @@ + "./index.js": (function (__unused_webpack_module, __webpack_exports__, __webpack_require__) { + "use strict"; + __webpack_require__.r(__webpack_exports__); +-__webpack_require__.d(__webpack_exports__, { +- test: function() { return test; } +-}); + /* harmony import */var _antd_index__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./antd/index */"./antd/index.js"); + + _antd_index__WEBPACK_IMPORTED_MODULE_0__.locales.zh_CN; +@@ -38,10 +35,11 @@ + var __WEBPACK_DEFAULT_EXPORT__ = _zh_locale__WEBPACK_IMPORTED_MODULE_0__["default"]; + }), "./zh_locale.js": (function (__unused_webpack_module, exports) { +var __webpack_unused_export__; "use strict"; @@ -14,13 +24,3 @@ exports["default"] = void 0; /* eslint-disable no-template-curly-in-string */ var _default = {}; exports["default"] = _default; -@@ -28,9 +29,6 @@ - "./index.ts": (function (__unused_webpack_module, __webpack_exports__, __webpack_require__) { - "use strict"; - __webpack_require__.r(__webpack_exports__); --__webpack_require__.d(__webpack_exports__, { -- test: function() { return test; } --}); - /* harmony import */var _antd_index__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./antd/index */"./antd/index.ts"); - - _antd_index__WEBPACK_IMPORTED_MODULE_0__.locales.zh_CN; diff --git a/crates/rspack/tests/tree-shaking/handle-side-effects-commonjs-required/snapshot/new_treeshaking.snap b/crates/rspack/tests/tree-shaking/handle-side-effects-commonjs-required/snapshot/new_treeshaking.snap index 4283ab50ff2..b0c610197e1 100644 --- a/crates/rspack/tests/tree-shaking/handle-side-effects-commonjs-required/snapshot/new_treeshaking.snap +++ b/crates/rspack/tests/tree-shaking/handle-side-effects-commonjs-required/snapshot/new_treeshaking.snap @@ -7,69 +7,26 @@ source: crates/rspack_testing/src/run_fixture.rs __webpack_require__(/*! ./source */"./source/index.js"); console.log('something'); }), -"./source/index.js": (function (module, __unused_webpack_exports, __webpack_require__) { -var _class_call_check = __webpack_require__(/*! @swc/helpers/_/_class_call_check */"../../../../../node_modules/@swc/helpers/esm/_class_call_check.js"); -var _create_class = __webpack_require__(/*! @swc/helpers/_/_create_class */"../../../../../node_modules/@swc/helpers/esm/_create_class.js"); -var Response = function() { - "use strict"; - function Response(mode) { - _class_call_check._(this, Response); +"./source/index.js": (function (module) { +class Response { + /** + * @param {CompiledMode} mode + */ constructor(mode){ // eslint-disable-next-line no-undefined if (mode.data === undefined) mode.data = {}; this.data = mode.data; this.isMatchIgnored = false; } - _create_class._(Response, [ - { - key: "ignoreMatch", - value: function ignoreMatch() { - this.isMatchIgnored = true; - } - } - ]); - return Response; -}(); + ignoreMatch() { + this.isMatchIgnored = true; + } +} function test() { - var res = new Response(); + let res = new Response(); return res; } -var result = test(); +const result = test(); module.exports = result; -}), -"../../../../../node_modules/@swc/helpers/esm/_class_call_check.js": (function (__unused_webpack_module, __webpack_exports__, __webpack_require__) { -"use strict"; -__webpack_require__.r(__webpack_exports__); -__webpack_require__.d(__webpack_exports__, { - _: function() { return _class_call_check; }, - _class_call_check: function() { return _class_call_check; } -}); - function _class_call_check(instance, Constructor) { - if (!(instance instanceof Constructor)) throw new TypeError("Cannot call a class as a function"); -} - -}), -"../../../../../node_modules/@swc/helpers/esm/_create_class.js": (function (__unused_webpack_module, __webpack_exports__, __webpack_require__) { -"use strict"; -__webpack_require__.r(__webpack_exports__); -__webpack_require__.d(__webpack_exports__, { - _: function() { return _create_class; }, - _create_class: function() { return _create_class; } -}); -function _defineProperties(target, props) { - for(var i = 0; i < props.length; i++){ - var descriptor = props[i]; - descriptor.enumerable = descriptor.enumerable || false; - descriptor.configurable = true; - if ("value" in descriptor) descriptor.writable = true; - Object.defineProperty(target, descriptor.key, descriptor); - } -} - function _create_class(Constructor, protoProps, staticProps) { - if (protoProps) _defineProperties(Constructor.prototype, protoProps); - if (staticProps) _defineProperties(Constructor, staticProps); - return Constructor; -} - }), },function(__webpack_require__) { diff --git a/crates/rspack/tests/tree-shaking/handle-side-effects-commonjs-required/snapshot/output.snap b/crates/rspack/tests/tree-shaking/handle-side-effects-commonjs-required/snapshot/output.snap index 4283ab50ff2..b0c610197e1 100644 --- a/crates/rspack/tests/tree-shaking/handle-side-effects-commonjs-required/snapshot/output.snap +++ b/crates/rspack/tests/tree-shaking/handle-side-effects-commonjs-required/snapshot/output.snap @@ -7,69 +7,26 @@ source: crates/rspack_testing/src/run_fixture.rs __webpack_require__(/*! ./source */"./source/index.js"); console.log('something'); }), -"./source/index.js": (function (module, __unused_webpack_exports, __webpack_require__) { -var _class_call_check = __webpack_require__(/*! @swc/helpers/_/_class_call_check */"../../../../../node_modules/@swc/helpers/esm/_class_call_check.js"); -var _create_class = __webpack_require__(/*! @swc/helpers/_/_create_class */"../../../../../node_modules/@swc/helpers/esm/_create_class.js"); -var Response = function() { - "use strict"; - function Response(mode) { - _class_call_check._(this, Response); +"./source/index.js": (function (module) { +class Response { + /** + * @param {CompiledMode} mode + */ constructor(mode){ // eslint-disable-next-line no-undefined if (mode.data === undefined) mode.data = {}; this.data = mode.data; this.isMatchIgnored = false; } - _create_class._(Response, [ - { - key: "ignoreMatch", - value: function ignoreMatch() { - this.isMatchIgnored = true; - } - } - ]); - return Response; -}(); + ignoreMatch() { + this.isMatchIgnored = true; + } +} function test() { - var res = new Response(); + let res = new Response(); return res; } -var result = test(); +const result = test(); module.exports = result; -}), -"../../../../../node_modules/@swc/helpers/esm/_class_call_check.js": (function (__unused_webpack_module, __webpack_exports__, __webpack_require__) { -"use strict"; -__webpack_require__.r(__webpack_exports__); -__webpack_require__.d(__webpack_exports__, { - _: function() { return _class_call_check; }, - _class_call_check: function() { return _class_call_check; } -}); - function _class_call_check(instance, Constructor) { - if (!(instance instanceof Constructor)) throw new TypeError("Cannot call a class as a function"); -} - -}), -"../../../../../node_modules/@swc/helpers/esm/_create_class.js": (function (__unused_webpack_module, __webpack_exports__, __webpack_require__) { -"use strict"; -__webpack_require__.r(__webpack_exports__); -__webpack_require__.d(__webpack_exports__, { - _: function() { return _create_class; }, - _create_class: function() { return _create_class; } -}); -function _defineProperties(target, props) { - for(var i = 0; i < props.length; i++){ - var descriptor = props[i]; - descriptor.enumerable = descriptor.enumerable || false; - descriptor.configurable = true; - if ("value" in descriptor) descriptor.writable = true; - Object.defineProperty(target, descriptor.key, descriptor); - } -} - function _create_class(Constructor, protoProps, staticProps) { - if (protoProps) _defineProperties(Constructor.prototype, protoProps); - if (staticProps) _defineProperties(Constructor, staticProps); - return Constructor; -} - }), },function(__webpack_require__) { diff --git a/crates/rspack/tests/tree-shaking/ts-target-es5/index.ts b/crates/rspack/tests/tree-shaking/ts-target-es5/index.js similarity index 100% rename from crates/rspack/tests/tree-shaking/ts-target-es5/index.ts rename to crates/rspack/tests/tree-shaking/ts-target-es5/index.js diff --git a/crates/rspack/tests/tree-shaking/ts-target-es5/snapshot/new_treeshaking.snap b/crates/rspack/tests/tree-shaking/ts-target-es5/snapshot/new_treeshaking.snap index b3f8deeb29f..4e938081b91 100644 --- a/crates/rspack/tests/tree-shaking/ts-target-es5/snapshot/new_treeshaking.snap +++ b/crates/rspack/tests/tree-shaking/ts-target-es5/snapshot/new_treeshaking.snap @@ -3,499 +3,16 @@ source: crates/rspack_testing/src/run_fixture.rs --- ```js title=main.js (self['webpackChunkwebpack'] = self['webpackChunkwebpack'] || []).push([["main"], { -"../../../../../node_modules/@swc/helpers/esm/_async_to_generator.js": (function (__unused_webpack_module, __webpack_exports__, __webpack_require__) { +"./index.js": (function (__unused_webpack_module, __webpack_exports__, __webpack_require__) { "use strict"; __webpack_require__.r(__webpack_exports__); -__webpack_require__.d(__webpack_exports__, { - _: function() { return _async_to_generator; } -}); -function asyncGeneratorStep(gen, resolve, reject, _next, _throw, key, arg) { - try { - var info = gen[key](arg); - var value = info.value; - } catch (error) { - reject(error); - return; - } - if (info.done) resolve(value); - else Promise.resolve(value).then(_next, _throw); -} - function _async_to_generator(fn) { - return function() { - var self = this, args = arguments; - return new Promise(function(resolve, reject) { - var gen = fn.apply(self, args); - function _next(value) { - asyncGeneratorStep(gen, resolve, reject, _next, _throw, "next", value); - } - function _throw(err) { - asyncGeneratorStep(gen, resolve, reject, _next, _throw, "throw", err); - } - _next(undefined); - }); - }; -} - -}), -"../../../../../node_modules/tslib/tslib.es6.js": (function (__unused_webpack_module, __webpack_exports__, __webpack_require__) { -"use strict"; -__webpack_require__.r(__webpack_exports__); -__webpack_require__.d(__webpack_exports__, { - __generator: function() { return __generator; } -}); -/****************************************************************************** -Copyright (c) Microsoft Corporation. - -Permission to use, copy, modify, and/or distribute this software for any -purpose with or without fee is hereby granted. - -THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH -REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY -AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, -INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM -LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR -OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR -PERFORMANCE OF THIS SOFTWARE. -***************************************************************************** */ /* global Reflect, Promise */ var extendStatics = function(d, b) { - extendStatics = Object.setPrototypeOf || ({ - __proto__: [] - }) instanceof Array && function(d, b) { - d.__proto__ = b; - } || function(d, b) { - for(var p in b)if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; - }; - return extendStatics(d, b); -}; - function __extends(d, b) { - if (typeof b !== "function" && b !== null) throw new TypeError("Class extends value " + String(b) + " is not a constructor or null"); - extendStatics(d, b); - function __() { - this.constructor = d; - } - d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); -} - var __assign = function() { - __assign = Object.assign || function __assign(t) { - for(var s, i = 1, n = arguments.length; i < n; i++){ - s = arguments[i]; - for(var p in s)if (Object.prototype.hasOwnProperty.call(s, p)) t[p] = s[p]; - } - return t; - }; - return __assign.apply(this, arguments); -}; - function __rest(s, e) { - var t = {}; - for(var p in s)if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0) t[p] = s[p]; - if (s != null && typeof Object.getOwnPropertySymbols === "function") { - for(var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++)if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i])) t[p[i]] = s[p[i]]; - } - return t; -} - function __decorate(decorators, target, key, desc) { - var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d; - if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc); - else for(var i = decorators.length - 1; i >= 0; i--)if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r; - return c > 3 && r && Object.defineProperty(target, key, r), r; -} - function __param(paramIndex, decorator) { - return function(target, key) { - decorator(target, key, paramIndex); - }; -} - function __esDecorate(ctor, descriptorIn, decorators, contextIn, initializers, extraInitializers) { - function accept(f) { - if (f !== void 0 && typeof f !== "function") throw new TypeError("Function expected"); - return f; - } - var kind = contextIn.kind, key = kind === "getter" ? "get" : kind === "setter" ? "set" : "value"; - var target = !descriptorIn && ctor ? contextIn["static"] ? ctor : ctor.prototype : null; - var descriptor = descriptorIn || (target ? Object.getOwnPropertyDescriptor(target, contextIn.name) : {}); - var _, done = false; - for(var i = decorators.length - 1; i >= 0; i--){ - var context = {}; - for(var p in contextIn)context[p] = p === "access" ? {} : contextIn[p]; - for(var p in contextIn.access)context.access[p] = contextIn.access[p]; - context.addInitializer = function(f) { - if (done) throw new TypeError("Cannot add initializers after decoration has completed"); - extraInitializers.push(accept(f || null)); - }; - var result = (0, decorators[i])(kind === "accessor" ? { - get: descriptor.get, - set: descriptor.set - } : descriptor[key], context); - if (kind === "accessor") { - if (result === void 0) continue; - if (result === null || typeof result !== "object") throw new TypeError("Object expected"); - if (_ = accept(result.get)) descriptor.get = _; - if (_ = accept(result.set)) descriptor.set = _; - if (_ = accept(result.init)) initializers.push(_); - } else if (_ = accept(result)) { - if (kind === "field") initializers.push(_); - else descriptor[key] = _; - } - } - if (target) Object.defineProperty(target, contextIn.name, descriptor); - done = true; -} - function __runInitializers(thisArg, initializers, value) { - var useValue = arguments.length > 2; - for(var i = 0; i < initializers.length; i++)value = useValue ? initializers[i].call(thisArg, value) : initializers[i].call(thisArg); - return useValue ? value : void 0; -} - function __propKey(x) { - return typeof x === "symbol" ? x : "".concat(x); -} - function __setFunctionName(f, name, prefix) { - if (typeof name === "symbol") name = name.description ? "[".concat(name.description, "]") : ""; - return Object.defineProperty(f, "name", { - configurable: true, - value: prefix ? "".concat(prefix, " ", name) : name - }); -} - function __metadata(metadataKey, metadataValue) { - if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(metadataKey, metadataValue); -} - function __awaiter(thisArg, _arguments, P, generator) { - function adopt(value) { - return value instanceof P ? value : new P(function(resolve) { - resolve(value); - }); - } - return new (P || (P = Promise))(function(resolve, reject) { - function fulfilled(value) { - try { - step(generator.next(value)); - } catch (e) { - reject(e); - } - } - function rejected(value) { - try { - step(generator["throw"](value)); - } catch (e) { - reject(e); - } - } - function step(result) { - result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); - } - step((generator = generator.apply(thisArg, _arguments || [])).next()); - }); -} - function __generator(thisArg, body) { - var _ = { - label: 0, - sent: function() { - if (t[0] & 1) throw t[1]; - return t[1]; - }, - trys: [], - ops: [] - }, f, y, t, g; - return g = { - next: verb(0), - "throw": verb(1), - "return": verb(2) - }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { - return this; - }), g; - function verb(n) { - return function(v) { - return step([ - n, - v - ]); - }; - } - function step(op) { - if (f) throw new TypeError("Generator is already executing."); - while(g && (g = 0, op[0] && (_ = 0)), _)try { - if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t; - if (y = 0, t) op = [ - op[0] & 2, - t.value - ]; - switch(op[0]){ - case 0: - case 1: - t = op; - break; - case 4: - _.label++; - return { - value: op[1], - done: false - }; - case 5: - _.label++; - y = op[1]; - op = [ - 0 - ]; - continue; - case 7: - op = _.ops.pop(); - _.trys.pop(); - continue; - default: - if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { - _ = 0; - continue; - } - if (op[0] === 3 && (!t || op[1] > t[0] && op[1] < t[3])) { - _.label = op[1]; - break; - } - if (op[0] === 6 && _.label < t[1]) { - _.label = t[1]; - t = op; - break; - } - if (t && _.label < t[2]) { - _.label = t[2]; - _.ops.push(op); - break; - } - if (t[2]) _.ops.pop(); - _.trys.pop(); - continue; - } - op = body.call(thisArg, _); - } catch (e) { - op = [ - 6, - e - ]; - y = 0; - } finally{ - f = t = 0; - } - if (op[0] & 5) throw op[1]; - return { - value: op[0] ? op[1] : void 0, - done: true - }; - } -} - var __createBinding = Object.create ? function(o, m, k, k2) { - if (k2 === undefined) k2 = k; - var desc = Object.getOwnPropertyDescriptor(m, k); - if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) desc = { - enumerable: true, - get: function() { - return m[k]; - } - }; - Object.defineProperty(o, k2, desc); -} : function(o, m, k, k2) { - if (k2 === undefined) k2 = k; - o[k2] = m[k]; -}; - function __exportStar(m, o) { - for(var p in m)if (p !== "default" && !Object.prototype.hasOwnProperty.call(o, p)) __createBinding(o, m, p); -} - function __values(o) { - var s = typeof Symbol === "function" && Symbol.iterator, m = s && o[s], i = 0; - if (m) return m.call(o); - if (o && typeof o.length === "number") return { - next: function() { - if (o && i >= o.length) o = void 0; - return { - value: o && o[i++], - done: !o - }; - } - }; - throw new TypeError(s ? "Object is not iterable." : "Symbol.iterator is not defined."); -} - function __read(o, n) { - var m = typeof Symbol === "function" && o[Symbol.iterator]; - if (!m) return o; - var i = m.call(o), r, ar = [], e; - try { - while((n === void 0 || n-- > 0) && !(r = i.next()).done)ar.push(r.value); - } catch (error) { - e = { - error: error - }; - } finally{ - try { - if (r && !r.done && (m = i["return"])) m.call(i); - } finally{ - if (e) throw e.error; - } - } - return ar; -} -/** @deprecated */ function __spread() { - for(var ar = [], i = 0; i < arguments.length; i++)ar = ar.concat(__read(arguments[i])); - return ar; -} -/** @deprecated */ function __spreadArrays() { - for(var s = 0, i = 0, il = arguments.length; i < il; i++)s += arguments[i].length; - for(var r = Array(s), k = 0, i = 0; i < il; i++)for(var a = arguments[i], j = 0, jl = a.length; j < jl; j++, k++)r[k] = a[j]; - return r; -} - function __spreadArray(to, from, pack) { - if (pack || arguments.length === 2) { - for(var i = 0, l = from.length, ar; i < l; i++)if (ar || !(i in from)) { - if (!ar) ar = Array.prototype.slice.call(from, 0, i); - ar[i] = from[i]; - } - } - return to.concat(ar || Array.prototype.slice.call(from)); -} - function __await(v) { - return this instanceof __await ? (this.v = v, this) : new __await(v); -} - function __asyncGenerator(thisArg, _arguments, generator) { - if (!Symbol.asyncIterator) throw new TypeError("Symbol.asyncIterator is not defined."); - var g = generator.apply(thisArg, _arguments || []), i, q = []; - return i = {}, verb("next"), verb("throw"), verb("return"), i[Symbol.asyncIterator] = function() { - return this; - }, i; - function verb(n) { - if (g[n]) i[n] = function(v) { - return new Promise(function(a, b) { - q.push([ - n, - v, - a, - b - ]) > 1 || resume(n, v); - }); - }; - } - function resume(n, v) { - try { - step(g[n](v)); - } catch (e) { - settle(q[0][3], e); - } - } - function step(r) { - r.value instanceof __await ? Promise.resolve(r.value.v).then(fulfill, reject) : settle(q[0][2], r); - } - function fulfill(value) { - resume("next", value); - } - function reject(value) { - resume("throw", value); - } - function settle(f, v) { - if (f(v), q.shift(), q.length) resume(q[0][0], q[0][1]); - } -} - function __asyncDelegator(o) { - var i, p; - return i = {}, verb("next"), verb("throw", function(e) { - throw e; - }), verb("return"), i[Symbol.iterator] = function() { - return this; - }, i; - function verb(n, f) { - i[n] = o[n] ? function(v) { - return (p = !p) ? { - value: __await(o[n](v)), - done: false - } : f ? f(v) : v; - } : f; - } -} - function __asyncValues(o) { - if (!Symbol.asyncIterator) throw new TypeError("Symbol.asyncIterator is not defined."); - var m = o[Symbol.asyncIterator], i; - return m ? m.call(o) : (o = typeof __values === "function" ? __values(o) : o[Symbol.iterator](), i = {}, verb("next"), verb("throw"), verb("return"), i[Symbol.asyncIterator] = function() { - return this; - }, i); - function verb(n) { - i[n] = o[n] && function(v) { - return new Promise(function(resolve, reject) { - v = o[n](v), settle(resolve, reject, v.done, v.value); - }); - }; - } - function settle(resolve, reject, d, v) { - Promise.resolve(v).then(function(v) { - resolve({ - value: v, - done: d - }); - }, reject); - } -} - function __makeTemplateObject(cooked, raw) { - if (Object.defineProperty) Object.defineProperty(cooked, "raw", { - value: raw - }); - else cooked.raw = raw; - return cooked; -} -var __setModuleDefault = Object.create ? function(o, v) { - Object.defineProperty(o, "default", { - enumerable: true, - value: v - }); -} : function(o, v) { - o["default"] = v; -}; - function __importStar(mod) { - if (mod && mod.__esModule) return mod; - var result = {}; - if (mod != null) { - for(var k in mod)if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k); - } - __setModuleDefault(result, mod); - return result; -} - function __importDefault(mod) { - return mod && mod.__esModule ? mod : { - default: mod - }; -} - function __classPrivateFieldGet(receiver, state, kind, f) { - if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a getter"); - if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError("Cannot read private member from an object whose class did not declare it"); - return kind === "m" ? f : kind === "a" ? f.call(receiver) : f ? f.value : state.get(receiver); -} - function __classPrivateFieldSet(receiver, state, value, kind, f) { - if (kind === "m") throw new TypeError("Private method is not writable"); - if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a setter"); - if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError("Cannot write private member to an object whose class did not declare it"); - return kind === "a" ? f.call(receiver, value) : f ? f.value = value : state.set(receiver, value), value; -} - function __classPrivateFieldIn(state, receiver) { - if (receiver === null || typeof receiver !== "object" && typeof receiver !== "function") throw new TypeError("Cannot use 'in' operator on non-object"); - return typeof state === "function" ? receiver === state : state.has(receiver); -} -}), -"./index.ts": (function (__unused_webpack_module, __webpack_exports__, __webpack_require__) { -"use strict"; -__webpack_require__.r(__webpack_exports__); -/* harmony import */var _swc_helpers_async_to_generator__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! @swc/helpers/_/_async_to_generator */"../../../../../node_modules/@swc/helpers/esm/_async_to_generator.js"); -/* harmony import */var _swc_helpers_ts_generator__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! @swc/helpers/_/_ts_generator */"../../../../../node_modules/tslib/tslib.es6.js"); - - - function test() { - return _test.apply(this, arguments); -} -function _test() { - _test = (0, _swc_helpers_async_to_generator__WEBPACK_IMPORTED_MODULE_0__._)(function() { - return (0, _swc_helpers_ts_generator__WEBPACK_IMPORTED_MODULE_1__.__generator)(this, function(_state) { - return [ - 2 - ]; - }); - }); - return _test.apply(this, arguments); -} + async function test() {} test(); }), },function(__webpack_require__) { var __webpack_exec__ = function(moduleId) { return __webpack_require__(__webpack_require__.s = moduleId) } -var __webpack_exports__ = (__webpack_exec__("./index.ts")); +var __webpack_exports__ = (__webpack_exec__("./index.js")); } ]); diff --git a/crates/rspack/tests/tree-shaking/ts-target-es5/snapshot/output.snap b/crates/rspack/tests/tree-shaking/ts-target-es5/snapshot/output.snap index 0c0d606db2f..0d2e2c5f759 100644 --- a/crates/rspack/tests/tree-shaking/ts-target-es5/snapshot/output.snap +++ b/crates/rspack/tests/tree-shaking/ts-target-es5/snapshot/output.snap @@ -3,511 +3,19 @@ source: crates/rspack_testing/src/run_fixture.rs --- ```js title=main.js (self['webpackChunkwebpack'] = self['webpackChunkwebpack'] || []).push([["main"], { -"../../../../../node_modules/@swc/helpers/esm/_async_to_generator.js": (function (__unused_webpack_module, __webpack_exports__, __webpack_require__) { -"use strict"; -__webpack_require__.r(__webpack_exports__); -__webpack_require__.d(__webpack_exports__, { - _: function() { return _async_to_generator; } -}); -function asyncGeneratorStep(gen, resolve, reject, _next, _throw, key, arg) { - try { - var info = gen[key](arg); - var value = info.value; - } catch (error) { - reject(error); - return; - } - if (info.done) resolve(value); - else Promise.resolve(value).then(_next, _throw); -} - function _async_to_generator(fn) { - return function() { - var self = this, args = arguments; - return new Promise(function(resolve, reject) { - var gen = fn.apply(self, args); - function _next(value) { - asyncGeneratorStep(gen, resolve, reject, _next, _throw, "next", value); - } - function _throw(err) { - asyncGeneratorStep(gen, resolve, reject, _next, _throw, "throw", err); - } - _next(undefined); - }); - }; -} - -}), -"../../../../../node_modules/@swc/helpers/esm/_ts_generator.js": (function (__unused_webpack_module, __webpack_exports__, __webpack_require__) { -"use strict"; -__webpack_require__.r(__webpack_exports__); -__webpack_require__.d(__webpack_exports__, { - _: function() { return tslib__WEBPACK_IMPORTED_MODULE_0__.__generator; } -}); -/* harmony import */var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */"../../../../../node_modules/tslib/tslib.es6.js"); - -}), -"../../../../../node_modules/tslib/tslib.es6.js": (function (__unused_webpack_module, __webpack_exports__, __webpack_require__) { -"use strict"; -__webpack_require__.r(__webpack_exports__); -__webpack_require__.d(__webpack_exports__, { - __generator: function() { return __generator; } -}); -/****************************************************************************** -Copyright (c) Microsoft Corporation. - -Permission to use, copy, modify, and/or distribute this software for any -purpose with or without fee is hereby granted. - -THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH -REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY -AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, -INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM -LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR -OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR -PERFORMANCE OF THIS SOFTWARE. -***************************************************************************** */ /* global Reflect, Promise */ var extendStatics = function(d, b) { - extendStatics = Object.setPrototypeOf || ({ - __proto__: [] - }) instanceof Array && function(d, b) { - d.__proto__ = b; - } || function(d, b) { - for(var p in b)if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; - }; - return extendStatics(d, b); -}; - function __extends(d, b) { - if (typeof b !== "function" && b !== null) throw new TypeError("Class extends value " + String(b) + " is not a constructor or null"); - extendStatics(d, b); - function __() { - this.constructor = d; - } - d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); -} - var __assign = function() { - __assign = Object.assign || function __assign(t) { - for(var s, i = 1, n = arguments.length; i < n; i++){ - s = arguments[i]; - for(var p in s)if (Object.prototype.hasOwnProperty.call(s, p)) t[p] = s[p]; - } - return t; - }; - return __assign.apply(this, arguments); -}; - function __rest(s, e) { - var t = {}; - for(var p in s)if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0) t[p] = s[p]; - if (s != null && typeof Object.getOwnPropertySymbols === "function") { - for(var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++)if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i])) t[p[i]] = s[p[i]]; - } - return t; -} - function __decorate(decorators, target, key, desc) { - var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d; - if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc); - else for(var i = decorators.length - 1; i >= 0; i--)if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r; - return c > 3 && r && Object.defineProperty(target, key, r), r; -} - function __param(paramIndex, decorator) { - return function(target, key) { - decorator(target, key, paramIndex); - }; -} - function __esDecorate(ctor, descriptorIn, decorators, contextIn, initializers, extraInitializers) { - function accept(f) { - if (f !== void 0 && typeof f !== "function") throw new TypeError("Function expected"); - return f; - } - var kind = contextIn.kind, key = kind === "getter" ? "get" : kind === "setter" ? "set" : "value"; - var target = !descriptorIn && ctor ? contextIn["static"] ? ctor : ctor.prototype : null; - var descriptor = descriptorIn || (target ? Object.getOwnPropertyDescriptor(target, contextIn.name) : {}); - var _, done = false; - for(var i = decorators.length - 1; i >= 0; i--){ - var context = {}; - for(var p in contextIn)context[p] = p === "access" ? {} : contextIn[p]; - for(var p in contextIn.access)context.access[p] = contextIn.access[p]; - context.addInitializer = function(f) { - if (done) throw new TypeError("Cannot add initializers after decoration has completed"); - extraInitializers.push(accept(f || null)); - }; - var result = (0, decorators[i])(kind === "accessor" ? { - get: descriptor.get, - set: descriptor.set - } : descriptor[key], context); - if (kind === "accessor") { - if (result === void 0) continue; - if (result === null || typeof result !== "object") throw new TypeError("Object expected"); - if (_ = accept(result.get)) descriptor.get = _; - if (_ = accept(result.set)) descriptor.set = _; - if (_ = accept(result.init)) initializers.push(_); - } else if (_ = accept(result)) { - if (kind === "field") initializers.push(_); - else descriptor[key] = _; - } - } - if (target) Object.defineProperty(target, contextIn.name, descriptor); - done = true; -} - function __runInitializers(thisArg, initializers, value) { - var useValue = arguments.length > 2; - for(var i = 0; i < initializers.length; i++)value = useValue ? initializers[i].call(thisArg, value) : initializers[i].call(thisArg); - return useValue ? value : void 0; -} - function __propKey(x) { - return typeof x === "symbol" ? x : "".concat(x); -} - function __setFunctionName(f, name, prefix) { - if (typeof name === "symbol") name = name.description ? "[".concat(name.description, "]") : ""; - return Object.defineProperty(f, "name", { - configurable: true, - value: prefix ? "".concat(prefix, " ", name) : name - }); -} - function __metadata(metadataKey, metadataValue) { - if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(metadataKey, metadataValue); -} - function __awaiter(thisArg, _arguments, P, generator) { - function adopt(value) { - return value instanceof P ? value : new P(function(resolve) { - resolve(value); - }); - } - return new (P || (P = Promise))(function(resolve, reject) { - function fulfilled(value) { - try { - step(generator.next(value)); - } catch (e) { - reject(e); - } - } - function rejected(value) { - try { - step(generator["throw"](value)); - } catch (e) { - reject(e); - } - } - function step(result) { - result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); - } - step((generator = generator.apply(thisArg, _arguments || [])).next()); - }); -} - function __generator(thisArg, body) { - var _ = { - label: 0, - sent: function() { - if (t[0] & 1) throw t[1]; - return t[1]; - }, - trys: [], - ops: [] - }, f, y, t, g; - return g = { - next: verb(0), - "throw": verb(1), - "return": verb(2) - }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { - return this; - }), g; - function verb(n) { - return function(v) { - return step([ - n, - v - ]); - }; - } - function step(op) { - if (f) throw new TypeError("Generator is already executing."); - while(g && (g = 0, op[0] && (_ = 0)), _)try { - if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t; - if (y = 0, t) op = [ - op[0] & 2, - t.value - ]; - switch(op[0]){ - case 0: - case 1: - t = op; - break; - case 4: - _.label++; - return { - value: op[1], - done: false - }; - case 5: - _.label++; - y = op[1]; - op = [ - 0 - ]; - continue; - case 7: - op = _.ops.pop(); - _.trys.pop(); - continue; - default: - if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { - _ = 0; - continue; - } - if (op[0] === 3 && (!t || op[1] > t[0] && op[1] < t[3])) { - _.label = op[1]; - break; - } - if (op[0] === 6 && _.label < t[1]) { - _.label = t[1]; - t = op; - break; - } - if (t && _.label < t[2]) { - _.label = t[2]; - _.ops.push(op); - break; - } - if (t[2]) _.ops.pop(); - _.trys.pop(); - continue; - } - op = body.call(thisArg, _); - } catch (e) { - op = [ - 6, - e - ]; - y = 0; - } finally{ - f = t = 0; - } - if (op[0] & 5) throw op[1]; - return { - value: op[0] ? op[1] : void 0, - done: true - }; - } -} - var __createBinding = Object.create ? function(o, m, k, k2) { - if (k2 === undefined) k2 = k; - var desc = Object.getOwnPropertyDescriptor(m, k); - if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) desc = { - enumerable: true, - get: function() { - return m[k]; - } - }; - Object.defineProperty(o, k2, desc); -} : function(o, m, k, k2) { - if (k2 === undefined) k2 = k; - o[k2] = m[k]; -}; - function __exportStar(m, o) { - for(var p in m)if (p !== "default" && !Object.prototype.hasOwnProperty.call(o, p)) __createBinding(o, m, p); -} - function __values(o) { - var s = typeof Symbol === "function" && Symbol.iterator, m = s && o[s], i = 0; - if (m) return m.call(o); - if (o && typeof o.length === "number") return { - next: function() { - if (o && i >= o.length) o = void 0; - return { - value: o && o[i++], - done: !o - }; - } - }; - throw new TypeError(s ? "Object is not iterable." : "Symbol.iterator is not defined."); -} - function __read(o, n) { - var m = typeof Symbol === "function" && o[Symbol.iterator]; - if (!m) return o; - var i = m.call(o), r, ar = [], e; - try { - while((n === void 0 || n-- > 0) && !(r = i.next()).done)ar.push(r.value); - } catch (error) { - e = { - error: error - }; - } finally{ - try { - if (r && !r.done && (m = i["return"])) m.call(i); - } finally{ - if (e) throw e.error; - } - } - return ar; -} -/** @deprecated */ function __spread() { - for(var ar = [], i = 0; i < arguments.length; i++)ar = ar.concat(__read(arguments[i])); - return ar; -} -/** @deprecated */ function __spreadArrays() { - for(var s = 0, i = 0, il = arguments.length; i < il; i++)s += arguments[i].length; - for(var r = Array(s), k = 0, i = 0; i < il; i++)for(var a = arguments[i], j = 0, jl = a.length; j < jl; j++, k++)r[k] = a[j]; - return r; -} - function __spreadArray(to, from, pack) { - if (pack || arguments.length === 2) { - for(var i = 0, l = from.length, ar; i < l; i++)if (ar || !(i in from)) { - if (!ar) ar = Array.prototype.slice.call(from, 0, i); - ar[i] = from[i]; - } - } - return to.concat(ar || Array.prototype.slice.call(from)); -} - function __await(v) { - return this instanceof __await ? (this.v = v, this) : new __await(v); -} - function __asyncGenerator(thisArg, _arguments, generator) { - if (!Symbol.asyncIterator) throw new TypeError("Symbol.asyncIterator is not defined."); - var g = generator.apply(thisArg, _arguments || []), i, q = []; - return i = {}, verb("next"), verb("throw"), verb("return"), i[Symbol.asyncIterator] = function() { - return this; - }, i; - function verb(n) { - if (g[n]) i[n] = function(v) { - return new Promise(function(a, b) { - q.push([ - n, - v, - a, - b - ]) > 1 || resume(n, v); - }); - }; - } - function resume(n, v) { - try { - step(g[n](v)); - } catch (e) { - settle(q[0][3], e); - } - } - function step(r) { - r.value instanceof __await ? Promise.resolve(r.value.v).then(fulfill, reject) : settle(q[0][2], r); - } - function fulfill(value) { - resume("next", value); - } - function reject(value) { - resume("throw", value); - } - function settle(f, v) { - if (f(v), q.shift(), q.length) resume(q[0][0], q[0][1]); - } -} - function __asyncDelegator(o) { - var i, p; - return i = {}, verb("next"), verb("throw", function(e) { - throw e; - }), verb("return"), i[Symbol.iterator] = function() { - return this; - }, i; - function verb(n, f) { - i[n] = o[n] ? function(v) { - return (p = !p) ? { - value: __await(o[n](v)), - done: false - } : f ? f(v) : v; - } : f; - } -} - function __asyncValues(o) { - if (!Symbol.asyncIterator) throw new TypeError("Symbol.asyncIterator is not defined."); - var m = o[Symbol.asyncIterator], i; - return m ? m.call(o) : (o = typeof __values === "function" ? __values(o) : o[Symbol.iterator](), i = {}, verb("next"), verb("throw"), verb("return"), i[Symbol.asyncIterator] = function() { - return this; - }, i); - function verb(n) { - i[n] = o[n] && function(v) { - return new Promise(function(resolve, reject) { - v = o[n](v), settle(resolve, reject, v.done, v.value); - }); - }; - } - function settle(resolve, reject, d, v) { - Promise.resolve(v).then(function(v) { - resolve({ - value: v, - done: d - }); - }, reject); - } -} - function __makeTemplateObject(cooked, raw) { - if (Object.defineProperty) Object.defineProperty(cooked, "raw", { - value: raw - }); - else cooked.raw = raw; - return cooked; -} -var __setModuleDefault = Object.create ? function(o, v) { - Object.defineProperty(o, "default", { - enumerable: true, - value: v - }); -} : function(o, v) { - o["default"] = v; -}; - function __importStar(mod) { - if (mod && mod.__esModule) return mod; - var result = {}; - if (mod != null) { - for(var k in mod)if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k); - } - __setModuleDefault(result, mod); - return result; -} - function __importDefault(mod) { - return mod && mod.__esModule ? mod : { - default: mod - }; -} - function __classPrivateFieldGet(receiver, state, kind, f) { - if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a getter"); - if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError("Cannot read private member from an object whose class did not declare it"); - return kind === "m" ? f : kind === "a" ? f.call(receiver) : f ? f.value : state.get(receiver); -} - function __classPrivateFieldSet(receiver, state, value, kind, f) { - if (kind === "m") throw new TypeError("Private method is not writable"); - if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a setter"); - if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError("Cannot write private member to an object whose class did not declare it"); - return kind === "a" ? f.call(receiver, value) : f ? f.value = value : state.set(receiver, value), value; -} - function __classPrivateFieldIn(state, receiver) { - if (receiver === null || typeof receiver !== "object" && typeof receiver !== "function") throw new TypeError("Cannot use 'in' operator on non-object"); - return typeof state === "function" ? receiver === state : state.has(receiver); -} -}), -"./index.ts": (function (__unused_webpack_module, __webpack_exports__, __webpack_require__) { +"./index.js": (function (__unused_webpack_module, __webpack_exports__, __webpack_require__) { "use strict"; __webpack_require__.r(__webpack_exports__); __webpack_require__.d(__webpack_exports__, { test: function() { return test; } }); -/* harmony import */var _swc_helpers_async_to_generator__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! @swc/helpers/_/_async_to_generator */"../../../../../node_modules/@swc/helpers/esm/_async_to_generator.js"); -/* harmony import */var _swc_helpers_ts_generator__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! @swc/helpers/_/_ts_generator */"../../../../../node_modules/@swc/helpers/esm/_ts_generator.js"); - - - function test() { - return _test.apply(this, arguments); -} -function _test() { - _test = (0, _swc_helpers_async_to_generator__WEBPACK_IMPORTED_MODULE_0__._)(function() { - return (0, _swc_helpers_ts_generator__WEBPACK_IMPORTED_MODULE_1__._)(this, function(_state) { - return [ - 2 - ]; - }); - }); - return _test.apply(this, arguments); -} + async function test() {} test(); }), },function(__webpack_require__) { var __webpack_exec__ = function(moduleId) { return __webpack_require__(__webpack_require__.s = moduleId) } -var __webpack_exports__ = (__webpack_exec__("./index.ts")); +var __webpack_exports__ = (__webpack_exec__("./index.js")); } ]); diff --git a/crates/rspack/tests/tree-shaking/ts-target-es5/snapshot/snap.diff b/crates/rspack/tests/tree-shaking/ts-target-es5/snapshot/snap.diff index 04d52c3653e..e54d0a7d7bc 100644 --- a/crates/rspack/tests/tree-shaking/ts-target-es5/snapshot/snap.diff +++ b/crates/rspack/tests/tree-shaking/ts-target-es5/snapshot/snap.diff @@ -1,40 +1,12 @@ --- expected +++ actual -@@ -37,15 +37,6 @@ - } - - }), --"../../../../../node_modules/@swc/helpers/esm/_ts_generator.js": (function (__unused_webpack_module, __webpack_exports__, __webpack_require__) { --"use strict"; --__webpack_require__.r(__webpack_exports__); --__webpack_require__.d(__webpack_exports__, { -- _: function() { return tslib__WEBPACK_IMPORTED_MODULE_0__.__generator; } --}); --/* harmony import */var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */"../../../../../node_modules/tslib/tslib.es6.js"); -- --}), - "../../../../../node_modules/tslib/tslib.es6.js": (function (__unused_webpack_module, __webpack_exports__, __webpack_require__) { - "use strict"; - __webpack_require__.r(__webpack_exports__); -@@ -482,11 +473,8 @@ - "./index.ts": (function (__unused_webpack_module, __webpack_exports__, __webpack_require__) { +@@ -6,9 +6,6 @@ + "./index.js": (function (__unused_webpack_module, __webpack_exports__, __webpack_require__) { "use strict"; __webpack_require__.r(__webpack_exports__); -__webpack_require__.d(__webpack_exports__, { - test: function() { return test; } -}); - /* harmony import */var _swc_helpers_async_to_generator__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! @swc/helpers/_/_async_to_generator */"../../../../../node_modules/@swc/helpers/esm/_async_to_generator.js"); --/* harmony import */var _swc_helpers_ts_generator__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! @swc/helpers/_/_ts_generator */"../../../../../node_modules/@swc/helpers/esm/_ts_generator.js"); -+/* harmony import */var _swc_helpers_ts_generator__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! @swc/helpers/_/_ts_generator */"../../../../../node_modules/tslib/tslib.es6.js"); - - - function test() { -@@ -494,7 +482,7 @@ - } - function _test() { - _test = (0, _swc_helpers_async_to_generator__WEBPACK_IMPORTED_MODULE_0__._)(function() { -- return (0, _swc_helpers_ts_generator__WEBPACK_IMPORTED_MODULE_1__._)(this, function(_state) { -+ return (0, _swc_helpers_ts_generator__WEBPACK_IMPORTED_MODULE_1__.__generator)(this, function(_state) { - return [ - 2 - ]; + async function test() {} + test(); + }), diff --git a/crates/rspack/tests/tree-shaking/ts-target-es5/test.config.json b/crates/rspack/tests/tree-shaking/ts-target-es5/test.config.json index 0b350c035dd..8a24d2060d9 100644 --- a/crates/rspack/tests/tree-shaking/ts-target-es5/test.config.json +++ b/crates/rspack/tests/tree-shaking/ts-target-es5/test.config.json @@ -12,4 +12,4 @@ "process.env.NODE_ENV": "'development'" } } -} \ No newline at end of file +} diff --git a/crates/rspack_binding_options/Cargo.toml b/crates/rspack_binding_options/Cargo.toml index 58ed9ad45dc..d0f325095e7 100644 --- a/crates/rspack_binding_options/Cargo.toml +++ b/crates/rspack_binding_options/Cargo.toml @@ -6,49 +6,46 @@ repository = "https://github.com/web-infra-dev/rspack" version = "0.1.0" [dependencies] -rspack_binding_macros = { path = "../rspack_binding_macros" } -rspack_binding_values = { path = "../rspack_binding_values" } -rspack_core = { path = "../rspack_core" } -rspack_error = { path = "../rspack_error" } -rspack_identifier = { path = "../rspack_identifier" } -rspack_ids = { path = "../rspack_ids" } -rspack_loader_react_refresh = { path = "../rspack_loader_react_refresh" } -rspack_loader_runner = { path = "../rspack_loader_runner" } -rspack_loader_sass = { path = "../rspack_loader_sass" } -rspack_loader_swc = { path = "../rspack_loader_swc" } -rspack_napi_shared = { path = "../rspack_napi_shared" } -rspack_plugin_asset = { path = "../rspack_plugin_asset" } -rspack_plugin_banner = { path = "../rspack_plugin_banner" } -rspack_plugin_copy = { path = "../rspack_plugin_copy" } -rspack_plugin_css = { path = "../rspack_plugin_css" } -rspack_plugin_dev_friendly_split_chunks = { path = "../rspack_plugin_dev_friendly_split_chunks" } -rspack_plugin_devtool = { path = "../rspack_plugin_devtool" } -rspack_plugin_ensure_chunk_conditions = { path = "../rspack_plugin_ensure_chunk_conditions" } -rspack_plugin_entry = { path = "../rspack_plugin_entry" } -rspack_plugin_externals = { path = "../rspack_plugin_externals" } -rspack_plugin_hmr = { path = "../rspack_plugin_hmr" } -rspack_plugin_html = { path = "../rspack_plugin_html" } -rspack_plugin_javascript = { path = "../rspack_plugin_javascript" } -rspack_plugin_json = { path = "../rspack_plugin_json" } -rspack_plugin_library = { path = "../rspack_plugin_library" } -rspack_plugin_limit_chunk_count = { path = "../rspack_plugin_limit_chunk_count" } -rspack_plugin_merge_duplicate_chunks = { path = "../rspack_plugin_merge_duplicate_chunks" } -rspack_plugin_mf = { path = "../rspack_plugin_mf" } -rspack_plugin_progress = { path = "../rspack_plugin_progress" } -rspack_plugin_real_content_hash = { path = "../rspack_plugin_real_content_hash" } -rspack_plugin_remove_empty_chunks = { path = "../rspack_plugin_remove_empty_chunks" } -rspack_plugin_runtime = { path = "../rspack_plugin_runtime" } -rspack_plugin_schemes = { path = "../rspack_plugin_schemes" } -rspack_plugin_split_chunks = { path = "../rspack_plugin_split_chunks" } -rspack_plugin_split_chunks_new = { path = "../rspack_plugin_split_chunks_new" } -rspack_plugin_swc_css_minimizer = { path = "../rspack_plugin_swc_css_minimizer" } -rspack_plugin_swc_js_minimizer = { path = "../rspack_plugin_swc_js_minimizer" } -rspack_plugin_warn_sensitive_module = { path = "../rspack_plugin_warn_sensitive_module" } -rspack_plugin_wasm = { path = "../rspack_plugin_wasm" } -rspack_plugin_web_worker_template = { path = "../rspack_plugin_web_worker_template" } -rspack_plugin_worker = { path = "../rspack_plugin_worker" } -rspack_regex = { path = "../rspack_regex" } -rspack_swc_visitors = { path = "../rspack_swc_visitors" } +rspack_binding_macros = { path = "../rspack_binding_macros" } +rspack_binding_values = { path = "../rspack_binding_values" } +rspack_core = { path = "../rspack_core" } +rspack_error = { path = "../rspack_error" } +rspack_identifier = { path = "../rspack_identifier" } +rspack_ids = { path = "../rspack_ids" } +rspack_loader_react_refresh = { path = "../rspack_loader_react_refresh" } +rspack_loader_runner = { path = "../rspack_loader_runner" } +rspack_loader_swc = { path = "../rspack_loader_swc" } +rspack_napi_shared = { path = "../rspack_napi_shared" } +rspack_plugin_asset = { path = "../rspack_plugin_asset" } +rspack_plugin_banner = { path = "../rspack_plugin_banner" } +rspack_plugin_copy = { path = "../rspack_plugin_copy" } +rspack_plugin_css = { path = "../rspack_plugin_css" } +rspack_plugin_devtool = { path = "../rspack_plugin_devtool" } +rspack_plugin_ensure_chunk_conditions = { path = "../rspack_plugin_ensure_chunk_conditions" } +rspack_plugin_entry = { path = "../rspack_plugin_entry" } +rspack_plugin_externals = { path = "../rspack_plugin_externals" } +rspack_plugin_hmr = { path = "../rspack_plugin_hmr" } +rspack_plugin_html = { path = "../rspack_plugin_html" } +rspack_plugin_javascript = { path = "../rspack_plugin_javascript" } +rspack_plugin_json = { path = "../rspack_plugin_json" } +rspack_plugin_library = { path = "../rspack_plugin_library" } +rspack_plugin_limit_chunk_count = { path = "../rspack_plugin_limit_chunk_count" } +rspack_plugin_merge_duplicate_chunks = { path = "../rspack_plugin_merge_duplicate_chunks" } +rspack_plugin_mf = { path = "../rspack_plugin_mf" } +rspack_plugin_progress = { path = "../rspack_plugin_progress" } +rspack_plugin_real_content_hash = { path = "../rspack_plugin_real_content_hash" } +rspack_plugin_remove_empty_chunks = { path = "../rspack_plugin_remove_empty_chunks" } +rspack_plugin_runtime = { path = "../rspack_plugin_runtime" } +rspack_plugin_schemes = { path = "../rspack_plugin_schemes" } +rspack_plugin_split_chunks_new = { path = "../rspack_plugin_split_chunks_new" } +rspack_plugin_swc_css_minimizer = { path = "../rspack_plugin_swc_css_minimizer" } +rspack_plugin_swc_js_minimizer = { path = "../rspack_plugin_swc_js_minimizer" } +rspack_plugin_warn_sensitive_module = { path = "../rspack_plugin_warn_sensitive_module" } +rspack_plugin_wasm = { path = "../rspack_plugin_wasm" } +rspack_plugin_web_worker_template = { path = "../rspack_plugin_web_worker_template" } +rspack_plugin_worker = { path = "../rspack_plugin_worker" } +rspack_regex = { path = "../rspack_regex" } +rspack_swc_visitors = { path = "../rspack_swc_visitors" } anyhow = { workspace = true, features = ["backtrace"] } async-trait = { workspace = true } diff --git a/crates/rspack_binding_options/src/options/mod.rs b/crates/rspack_binding_options/src/options/mod.rs index 839f02dc90e..44868aa3ab5 100644 --- a/crates/rspack_binding_options/src/options/mod.rs +++ b/crates/rspack_binding_options/src/options/mod.rs @@ -1,13 +1,12 @@ use napi_derive::napi; use rspack_core::{ - CompilerOptions, Context, DevServerOptions, Devtool, Experiments, IncrementalRebuild, - IncrementalRebuildMakeState, ModuleOptions, Optimization, OutputOptions, Target, TreeShaking, + CompilerOptions, Context, Devtool, Experiments, IncrementalRebuild, IncrementalRebuildMakeState, + ModuleOptions, Optimization, OutputOptions, Target, TreeShaking, }; use serde::Deserialize; mod raw_builtins; mod raw_cache; -mod raw_dev_server; mod raw_devtool; mod raw_entry; mod raw_experiments; @@ -24,7 +23,6 @@ mod raw_stats; pub use raw_builtins::*; pub use raw_cache::*; -pub use raw_dev_server::*; pub use raw_devtool::*; pub use raw_entry::*; pub use raw_experiments::*; @@ -59,7 +57,6 @@ pub struct RawOptions { pub devtool: String, pub optimization: RawOptimizationOptions, pub stats: RawStatsOptions, - pub dev_server: RawDevServer, pub snapshot: RawSnapshotOptions, pub cache: RawCacheOptions, pub experiments: RawExperiments, @@ -85,12 +82,8 @@ impl RawOptions { let cache = self.cache.into(); let experiments = Experiments { incremental_rebuild: IncrementalRebuild { - make: self - .experiments - .incremental_rebuild - .make - .then(IncrementalRebuildMakeState::default), - emit_asset: self.experiments.incremental_rebuild.emit_asset, + make: Some(IncrementalRebuildMakeState::default()), + emit_asset: true, }, new_split_chunks: self.experiments.new_split_chunks, top_level_await: self.experiments.top_level_await, @@ -103,7 +96,6 @@ impl RawOptions { let stats = self.stats.into(); let snapshot = self.snapshot.into(); let node = self.node.map(|n| n.into()); - let dev_server: DevServerOptions = self.dev_server.into(); let mut builtins = self.builtins.apply(plugins)?; if experiments.rspack_future.new_treeshaking { @@ -125,7 +117,7 @@ impl RawOptions { snapshot, optimization, node, - dev_server, + dev_server: Default::default(), profile: self.profile, bail: self.bail, builtins, diff --git a/crates/rspack_binding_options/src/options/raw_builtins/mod.rs b/crates/rspack_binding_options/src/options/raw_builtins/mod.rs index c1fce92bf54..4f42fe099e3 100644 --- a/crates/rspack_binding_options/src/options/raw_builtins/mod.rs +++ b/crates/rspack_binding_options/src/options/raw_builtins/mod.rs @@ -96,7 +96,6 @@ pub enum BuiltinPluginName { WebWorkerTemplatePlugin, MergeDuplicateChunksPlugin, SplitChunksPlugin, - OldSplitChunksPlugin, ShareRuntimePlugin, ContainerPlugin, ContainerReferencePlugin, @@ -237,11 +236,6 @@ impl BuiltinPlugin { let options = downcast_into::(self.options)?.into(); plugins.push(SplitChunksPlugin::new(options).boxed()); } - BuiltinPluginName::OldSplitChunksPlugin => { - use rspack_plugin_split_chunks::SplitChunksPlugin; - let options = downcast_into::(self.options)?.into(); - plugins.push(SplitChunksPlugin::new(options).boxed()); - } BuiltinPluginName::ShareRuntimePlugin => { plugins.push(ShareRuntimePlugin::new(downcast_into::(self.options)?).boxed()) } diff --git a/crates/rspack_binding_options/src/options/raw_builtins/raw_to_be_deprecated.rs b/crates/rspack_binding_options/src/options/raw_builtins/raw_to_be_deprecated.rs index 013841037ac..4a767c4595c 100644 --- a/crates/rspack_binding_options/src/options/raw_builtins/raw_to_be_deprecated.rs +++ b/crates/rspack_binding_options/src/options/raw_builtins/raw_to_be_deprecated.rs @@ -1,35 +1,16 @@ use std::{path::PathBuf, str::FromStr}; use napi_derive::napi; -use rspack_core::{Builtins, DecoratorOptions, PluginExt, PresetEnv}; -use rspack_error::error; +use rspack_core::{Builtins, PluginExt}; use rspack_plugin_css::{ plugin::{CssConfig, LocalIdentName, LocalsConvention, ModulesConfig}, CssPlugin, }; -use rspack_plugin_dev_friendly_split_chunks::DevFriendlySplitChunksPlugin; use rspack_swc_visitors::{ CustomTransform, ImportOptions, ReactOptions, RelayLanguageConfig, RelayOptions, StyleConfig, }; use serde::{Deserialize, Serialize}; -#[derive(Deserialize, Debug, Serialize, Default, Clone)] -#[serde(rename_all = "camelCase")] -#[napi(object)] -pub struct RawDecoratorOptions { - pub legacy: bool, - pub emit_metadata: bool, -} - -impl From for DecoratorOptions { - fn from(value: RawDecoratorOptions) -> Self { - Self { - legacy: value.legacy, - emit_metadata: value.emit_metadata, - } - } -} - #[derive(Debug, Deserialize)] #[serde(rename_all = "camelCase")] #[napi(object)] @@ -98,30 +79,6 @@ impl From for ImportOptions { } } -#[derive(Debug, Deserialize)] -#[serde(rename_all = "camelCase")] -#[napi(object)] -pub struct RawPresetEnv { - pub targets: Vec, - #[napi(ts_type = "'usage' | 'entry'")] - pub mode: Option, - pub core_js: Option, -} - -impl From for PresetEnv { - fn from(raw_preset_env: RawPresetEnv) -> Self { - Self { - targets: raw_preset_env.targets, - mode: raw_preset_env.mode.and_then(|mode| match mode.as_str() { - "usage" => Some(swc_core::ecma::preset_env::Mode::Usage), - "entry" => Some(swc_core::ecma::preset_env::Mode::Entry), - _ => None, - }), - core_js: raw_preset_env.core_js, - } - } -} - use swc_core::ecma::transforms::react::Runtime; #[derive(Deserialize, Debug, Serialize, Default, Clone)] @@ -222,15 +179,7 @@ impl TryFrom for ModulesConfig { #[napi(object)] pub struct RawBuiltins { pub css: Option, - pub preset_env: Option, pub tree_shaking: String, - pub react: RawReactOptions, - pub decorator: Option, - pub no_emit_assets: bool, - pub emotion: Option, - pub dev_friendly_split_chunks: bool, - pub plugin_import: Option>, - pub relay: Option, } impl RawBuiltins { @@ -241,27 +190,11 @@ impl RawBuiltins { }; plugins.push(CssPlugin::new(options).boxed()); } - if self.dev_friendly_split_chunks { - plugins.push(DevFriendlySplitChunksPlugin::new().boxed()); - } Ok(Builtins { define: Default::default(), provide: Default::default(), - preset_env: self.preset_env.map(Into::into), tree_shaking: self.tree_shaking.into(), - react: self.react.into(), - decorator: self.decorator.map(|i| i.into()), - no_emit_assets: self.no_emit_assets, - emotion: self - .emotion - .map(|i| serde_json::from_str(&i)) - .transpose() - .map_err(|e| error!(e.to_string()))?, - plugin_import: self - .plugin_import - .map(|plugin_imports| plugin_imports.into_iter().map(Into::into).collect()), - relay: self.relay.map(Into::into), }) } } diff --git a/crates/rspack_binding_options/src/options/raw_dev_server.rs b/crates/rspack_binding_options/src/options/raw_dev_server.rs deleted file mode 100644 index 375b75b2684..00000000000 --- a/crates/rspack_binding_options/src/options/raw_dev_server.rs +++ /dev/null @@ -1,16 +0,0 @@ -use napi_derive::napi; -use rspack_core::DevServerOptions; -use serde::Deserialize; - -#[derive(Deserialize, Debug, Default)] -#[serde(rename_all = "camelCase")] -#[napi(object)] -pub struct RawDevServer { - pub hot: bool, -} - -impl From for DevServerOptions { - fn from(value: RawDevServer) -> Self { - Self { hot: value.hot } - } -} diff --git a/crates/rspack_binding_options/src/options/raw_experiments.rs b/crates/rspack_binding_options/src/options/raw_experiments.rs index c3996897bb7..4c3bd935eec 100644 --- a/crates/rspack_binding_options/src/options/raw_experiments.rs +++ b/crates/rspack_binding_options/src/options/raw_experiments.rs @@ -2,28 +2,17 @@ use napi_derive::napi; use rspack_core::RspackFuture; use serde::Deserialize; -#[derive(Deserialize, Debug, Default)] -#[serde(rename_all = "camelCase")] -#[napi(object)] -pub struct RawIncrementalRebuild { - pub make: bool, - pub emit_asset: bool, -} - #[derive(Deserialize, Debug, Default)] #[serde(rename_all = "camelCase")] #[napi(object)] pub struct RawRspackFuture { - pub new_resolver: bool, pub new_treeshaking: bool, - pub disable_transform_by_default: bool, } #[derive(Deserialize, Debug, Default)] #[serde(rename_all = "camelCase")] #[napi(object)] pub struct RawExperiments { - pub incremental_rebuild: RawIncrementalRebuild, pub new_split_chunks: bool, pub top_level_await: bool, pub rspack_future: RawRspackFuture, @@ -32,9 +21,7 @@ pub struct RawExperiments { impl From for RspackFuture { fn from(value: RawRspackFuture) -> Self { Self { - new_resolver: value.new_resolver, new_treeshaking: value.new_treeshaking, - disable_transform_by_default: value.disable_transform_by_default, } } } diff --git a/crates/rspack_binding_options/src/options/raw_module/mod.rs b/crates/rspack_binding_options/src/options/raw_module/mod.rs index eadaf4d7b6f..0241ab0c536 100644 --- a/crates/rspack_binding_options/src/options/raw_module/mod.rs +++ b/crates/rspack_binding_options/src/options/raw_module/mod.rs @@ -15,7 +15,6 @@ use rspack_core::{ }; use rspack_error::{error, miette::IntoDiagnostic}; use rspack_loader_react_refresh::REACT_REFRESH_LOADER_IDENTIFIER; -use rspack_loader_sass::SASS_LOADER_IDENTIFIER; use rspack_loader_swc::SWC_LOADER_IDENTIFIER; use rspack_napi_shared::threadsafe_function::{ThreadsafeFunction, ThreadsafeFunctionCallMode}; use rspack_napi_shared::{get_napi_env, NapiResultExt}; @@ -26,14 +25,6 @@ pub use self::js_loader::*; use crate::RawResolveOptions; pub fn get_builtin_loader(builtin: &str, options: Option<&str>) -> BoxLoader { - if builtin.starts_with(SASS_LOADER_IDENTIFIER) { - return Arc::new(rspack_loader_sass::SassLoader::new( - serde_json::from_str(options.unwrap_or("{}")).unwrap_or_else(|e| { - panic!("Could not parse builtin:sass-loader options: {options:?}, error: {e:?}") - }), - )); - } - if builtin.starts_with(SWC_LOADER_IDENTIFIER) { return Arc::new( rspack_loader_swc::SwcLoader::new( diff --git a/crates/rspack_binding_options/src/options/raw_resolve.rs b/crates/rspack_binding_options/src/options/raw_resolve.rs index 924237f3479..f77df37db09 100644 --- a/crates/rspack_binding_options/src/options/raw_resolve.rs +++ b/crates/rspack_binding_options/src/options/raw_resolve.rs @@ -56,12 +56,12 @@ fn normalize_alias(alias: Option) -> rspack_error::Result