@rsbuild/webpack 0.1.5 → 0.1.7

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 (86) hide show
  1. package/README.md +26 -3
  2. package/dist/{webpackPlugins/ProgressPlugin → ProgressPlugin}/helpers/bar.js +1 -1
  3. package/dist/{webpackPlugins/ProgressPlugin → ProgressPlugin}/helpers/bus.js +2 -2
  4. package/dist/{webpackPlugins/ProgressPlugin → ProgressPlugin}/helpers/log.js +1 -1
  5. package/dist/core/createCompiler.d.ts +2 -1
  6. package/dist/core/createContext.d.ts +2 -2
  7. package/dist/core/createContext.js +4 -6
  8. package/dist/core/initConfigs.d.ts +2 -1
  9. package/dist/core/initConfigs.js +2 -3
  10. package/dist/core/inspectConfig.d.ts +2 -1
  11. package/dist/core/webpackConfig.d.ts +2 -1
  12. package/dist/index.d.ts +1 -4
  13. package/dist/index.js +0 -3
  14. package/dist/plugins/basic.d.ts +1 -1
  15. package/dist/plugins/copy.d.ts +1 -1
  16. package/dist/plugins/css.d.ts +1 -2
  17. package/dist/plugins/hmr.d.ts +1 -1
  18. package/dist/plugins/less.d.ts +1 -2
  19. package/dist/plugins/minimize.d.ts +1 -1
  20. package/dist/plugins/minimize.js +1 -5
  21. package/dist/plugins/output.d.ts +1 -1
  22. package/dist/plugins/progress.d.ts +1 -1
  23. package/dist/plugins/progress.js +1 -1
  24. package/dist/plugins/resolve.d.ts +1 -1
  25. package/dist/plugins/resolve.js +1 -1
  26. package/dist/plugins/sass.d.ts +1 -1
  27. package/dist/provider.d.ts +2 -4
  28. package/dist/provider.js +9 -17
  29. package/dist/shared.d.ts +3 -0
  30. package/dist/{shared/plugin.js → shared.js} +31 -19
  31. package/dist/types.d.ts +4 -0
  32. package/dist/{types/thirdParty/css.js → types.js} +2 -2
  33. package/package.json +4 -29
  34. package/compiled/babel-plugin-lodash/index.d.ts +0 -1
  35. package/compiled/babel-plugin-lodash/index.js +0 -1
  36. package/compiled/babel-plugin-lodash/license +0 -44
  37. package/compiled/babel-plugin-lodash/package.json +0 -1
  38. package/compiled/babel-plugin-transform-react-remove-prop-types/index.d.ts +0 -1
  39. package/compiled/babel-plugin-transform-react-remove-prop-types/index.js +0 -1
  40. package/compiled/babel-plugin-transform-react-remove-prop-types/license +0 -22
  41. package/compiled/babel-plugin-transform-react-remove-prop-types/package.json +0 -1
  42. package/dist/config/defaults.d.ts +0 -3
  43. package/dist/config/defaults.js +0 -47
  44. package/dist/config/normalize.d.ts +0 -7
  45. package/dist/config/normalize.js +0 -33
  46. package/dist/core/initHooks.d.ts +0 -20
  47. package/dist/core/initHooks.js +0 -46
  48. package/dist/core/initPlugins.d.ts +0 -9
  49. package/dist/core/initPlugins.js +0 -88
  50. package/dist/plugins/babel.d.ts +0 -2
  51. package/dist/plugins/babel.js +0 -157
  52. package/dist/plugins/react.d.ts +0 -2
  53. package/dist/plugins/react.js +0 -103
  54. package/dist/shared/fs.d.ts +0 -1
  55. package/dist/shared/fs.js +0 -48
  56. package/dist/shared/index.d.ts +0 -1
  57. package/dist/shared/index.js +0 -22
  58. package/dist/shared/plugin.d.ts +0 -3
  59. package/dist/types/config/index.d.ts +0 -26
  60. package/dist/types/config/index.js +0 -22
  61. package/dist/types/config/tools.d.ts +0 -42
  62. package/dist/types/config/tools.js +0 -16
  63. package/dist/types/context.d.ts +0 -17
  64. package/dist/types/context.js +0 -16
  65. package/dist/types/index.d.ts +0 -4
  66. package/dist/types/index.js +0 -28
  67. package/dist/types/plugin.d.ts +0 -5
  68. package/dist/types/plugin.js +0 -16
  69. package/dist/types/thirdParty/css.d.ts +0 -7
  70. package/dist/types/thirdParty/index.d.ts +0 -6
  71. package/dist/types/thirdParty/index.js +0 -16
  72. /package/dist/{webpackPlugins/ProgressPlugin → ProgressPlugin}/ProgressPlugin.d.ts +0 -0
  73. /package/dist/{webpackPlugins/ProgressPlugin → ProgressPlugin}/ProgressPlugin.js +0 -0
  74. /package/dist/{webpackPlugins/ProgressPlugin → ProgressPlugin}/helpers/bar.d.ts +0 -0
  75. /package/dist/{webpackPlugins/ProgressPlugin → ProgressPlugin}/helpers/bus.d.ts +0 -0
  76. /package/dist/{webpackPlugins/ProgressPlugin → ProgressPlugin}/helpers/index.d.ts +0 -0
  77. /package/dist/{webpackPlugins/ProgressPlugin → ProgressPlugin}/helpers/index.js +0 -0
  78. /package/dist/{webpackPlugins/ProgressPlugin → ProgressPlugin}/helpers/log.d.ts +0 -0
  79. /package/dist/{webpackPlugins/ProgressPlugin → ProgressPlugin}/helpers/nonTty.d.ts +0 -0
  80. /package/dist/{webpackPlugins/ProgressPlugin → ProgressPlugin}/helpers/nonTty.js +0 -0
  81. /package/dist/{webpackPlugins/ProgressPlugin → ProgressPlugin}/helpers/percentage.d.ts +0 -0
  82. /package/dist/{webpackPlugins/ProgressPlugin → ProgressPlugin}/helpers/percentage.js +0 -0
  83. /package/dist/{webpackPlugins/ProgressPlugin → ProgressPlugin}/helpers/type.d.ts +0 -0
  84. /package/dist/{webpackPlugins/ProgressPlugin → ProgressPlugin}/helpers/type.js +0 -0
  85. /package/dist/{webpackPlugins/ProgressPlugin → ProgressPlugin}/helpers/utils.d.ts +0 -0
  86. /package/dist/{webpackPlugins/ProgressPlugin → ProgressPlugin}/helpers/utils.js +0 -0
@@ -1,44 +0,0 @@
1
- Copyright JS Foundation and other contributors <https://js.foundation/>
2
-
3
- This software consists of voluntary contributions made by many
4
- individuals. For exact contribution history, see the revision history
5
- available at https://github.com/lodash/lodash
6
-
7
- The following license applies to all parts of this software except as
8
- documented below:
9
-
10
- ====
11
-
12
- Permission is hereby granted, free of charge, to any person obtaining
13
- a copy of this software and associated documentation files (the
14
- "Software"), to deal in the Software without restriction, including
15
- without limitation the rights to use, copy, modify, merge, publish,
16
- distribute, sublicense, and/or sell copies of the Software, and to
17
- permit persons to whom the Software is furnished to do so, subject to
18
- the following conditions:
19
-
20
- The above copyright notice and this permission notice shall be
21
- included in all copies or substantial portions of the Software.
22
-
23
- THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
24
- EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
25
- MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
26
- NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
27
- LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
28
- OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
29
- WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
30
-
31
- ====
32
-
33
- Copyright and related rights for sample code are waived via CC0. Sample
34
- code is defined as all source code displayed within the prose of the
35
- documentation.
36
-
37
- CC0: http://creativecommons.org/publicdomain/zero/1.0/
38
-
39
- ====
40
-
41
- Files located in the node_modules and vendor directories are externally
42
- maintained libraries used by this software which have their own
43
- licenses; we recommend you read them, as their terms may differ from the
44
- terms above.
@@ -1 +0,0 @@
1
- {"name":"babel-plugin-lodash","author":"Graeme Yeates <megawac@gmail.com> (https://github.com/megawac)","version":"3.3.4","license":"MIT","types":"index.d.ts"}
@@ -1 +0,0 @@
1
- (()=>{"use strict";var e={13:(e,r)=>{Object.defineProperty(r,"__esModule",{value:true});r["default"]=isAnnotatedForRemoval;function isAnnotatedForRemoval(e){var r=e.trailingComments||[];return Boolean(r.find((function(e){var r=e.value;return r.trim()==="remove-proptypes"})))}},551:(e,r)=>{Object.defineProperty(r,"__esModule",{value:true});r["default"]=isStatelessComponent;var t=Symbol("traversed");function isJSXElementOrReactCreateElement(e){var r=false;e.traverse({CallExpression:function CallExpression(e){var t=e.get("callee");if(t.matchesPattern("React.createElement")||t.matchesPattern("React.cloneElement")||t.node.name==="cloneElement"){r=true}},JSXElement:function JSXElement(){r=true}});return r}function isReturningJSXElement(e){var r=arguments.length>1&&arguments[1]!==undefined?arguments[1]:0;if(e.node.init&&e.node.init.body&&isJSXElementOrReactCreateElement(e)){return true}if(r>20){throw new Error("transform-react-remove-prop-type: infinite loop detected.")}var a=false;e.traverse({ReturnStatement:function ReturnStatement(n){if(a){return}var i=n.get("argument");if(!i.node){return}if(isJSXElementOrReactCreateElement(n)){a=true;return}if(i.node.type==="CallExpression"){var o=i.get("callee").node.name;var s=e.scope.getBinding(o);if(!s){return}if(s.path[t]){return}s.path[t]=true;if(isReturningJSXElement(s.path,r+1)){a=true}}}});return a}var a=["VariableDeclarator","FunctionDeclaration"];function isStatelessComponent(e){if(a.indexOf(e.node.type)===-1){return false}if(isReturningJSXElement(e)){return true}return false}},442:(e,r)=>{Object.defineProperty(r,"__esModule",{value:true});r["default"]=remove;function isInside(e,r){if(!e.hub.file.opts){return true}var t=e.hub.file.opts.filename;if(!t){return true}if(!r){return false}return r.test(t)}function remove(e,r,t){var a=r.visitedKey,n=r.unsafeWrapTemplate,i=r.wrapTemplate,o=r.mode,s=r.ignoreFilenames,u=r.types;if(s&&isInside(e.scope,s)){return}if(e.node[a]){return}e.node[a]=true;if(o==="remove"){if(e.parentPath.type==="ConditionalExpression"){e.replaceWith(u.unaryExpression("void",u.numericLiteral(0)))}else{e.remove()}return}if(o==="wrap"||o==="unsafe-wrap"){switch(t.type){case"createClass":break;case"class static":{var l;var p=t.pathClassDeclaration;if(!p.isClassExpression()&&p.node.id){l=p.node.id}else{return}var f=u.expressionStatement(u.assignmentExpression("=",u.memberExpression(l,e.node.key),e.node.value));if(p.parentPath.isExportDeclaration()){p=p.parentPath}p.insertAfter(f);e.remove();break}case"assign":if(o==="unsafe-wrap"){e.replaceWith(n({NODE:e.node}))}else{e.replaceWith(i({LEFT:e.node.left,RIGHT:e.node.right}))}e.node[a]=true;break;case"declarator":e.replaceWith(i({LEFT:e.node.id,RIGHT:e.node.init},{as:"variableDeclarator"}));e.node[a]=true;break;default:break}return}throw new Error("transform-react-remove-prop-type: unsupported mode ".concat(o,"."))}}};var r={};function __nccwpck_require__(t){var a=r[t];if(a!==undefined){return a.exports}var n=r[t]={exports:{}};var i=true;try{e[t](n,n.exports,__nccwpck_require__);i=false}finally{if(i)delete r[t]}return n.exports}if(typeof __nccwpck_require__!=="undefined")__nccwpck_require__.ab=__dirname+"/";var t={};(()=>{var e=t;Object.defineProperty(e,"__esModule",{value:true});e["default"]=_default;var r=_interopRequireDefault(__nccwpck_require__(13));var a=_interopRequireDefault(__nccwpck_require__(551));var n=_interopRequireDefault(__nccwpck_require__(442));function _interopRequireDefault(e){return e&&e.__esModule?e:{default:e}}function _objectSpread(e){for(var r=1;r<arguments.length;r++){var t=arguments[r]!=null?arguments[r]:{};var a=Object.keys(t);if(typeof Object.getOwnPropertySymbols==="function"){a=a.concat(Object.getOwnPropertySymbols(t).filter((function(e){return Object.getOwnPropertyDescriptor(t,e).enumerable})))}a.forEach((function(r){_defineProperty(e,r,t[r])}))}return e}function _defineProperty(e,r,t){if(r in e){Object.defineProperty(e,r,{value:t,enumerable:true,configurable:true,writable:true})}else{e[r]=t}return e}function isPathReactClass(e,r){var t=e.node;var a=r.classNameMatchers;if(e.matchesPattern("React.Component")||e.matchesPattern("React.PureComponent")){return true}if(t&&(t.name==="Component"||t.name==="PureComponent")){return true}if(t&&a&&a.test(t.name)){return true}return false}function isReactClass(e,r,t){if(!e.node){return false}var a=false;if(isPathReactClass(e,t)){a=true}else if(e.node.name){var n=e.node.name;var i=r.getBinding(n);if(!i){a=false}else{var o=i.path.get("superClass");if(isPathReactClass(o,t)){a=true}}}return a}function areSetsEqual(e,r){if(e===r){return true}if(e.size!==r.size){return false}return!Array.from(e).some((function(e){return!r.has(e)}))}function memberExpressionRootIdentifier(e){var r=e.findParent((function(e){return!e.isMemberExpression()}));var t=r.node.type;var a;if(t==="ObjectProperty"){a=r.get("value")}if(!a||a.type!=="MemberExpression"){return null}while(a.node.object.type==="MemberExpression"){a=a.get("object")}return a.get("object")}function _default(e){var t=e.template,i=e.types,o=e.traverse;var s=new Set;var u=new WeakSet;var l={Identifier:function Identifier(e){if(e.parent.type==="MemberExpression"){var r=memberExpressionRootIdentifier(e);if(r){s.add(r.node.name)}return}if(e.parent.type==="ObjectProperty"&&(e.parent.key===e.node||e.parent.shorthand)){return}s.add(e.node.name)}};return{visitor:{Program:function Program(p,f){var c;var d;if(f.opts.ignoreFilenames){c=new RegExp(f.opts.ignoreFilenames.join("|"),"i")}else{c=undefined}if(f.opts.classNameMatchers){d=new RegExp(f.opts.classNameMatchers.join("|"))}else{d=undefined}var m={visitedKey:"transform-react-remove-prop-types".concat(Date.now()),unsafeWrapTemplate:t('\n if (process.env.NODE_ENV !== "production") {\n NODE;\n }\n ',{placeholderPattern:/^NODE$/}),wrapTemplate:function wrapTemplate(e){var r=e.LEFT,a=e.RIGHT;var n=arguments.length>1&&arguments[1]!==undefined?arguments[1]:{};var o=n.as,s=o===void 0?"assignmentExpression":o;var u=t.expression('\n process.env.NODE_ENV !== "production" ? RIGHT : {}\n ',{placeholderPattern:/^(LEFT|RIGHT)$/})({RIGHT:a});switch(s){case"variableDeclarator":return i.variableDeclarator(r,u);case"assignmentExpression":return i.assignmentExpression("=",r,u);default:throw new Error("unrecognized template type ".concat(s))}},mode:f.opts.mode||"remove",ignoreFilenames:c,types:i,removeImport:f.opts.removeImport||false,libraries:(f.opts.additionalLibraries||[]).concat("prop-types"),classNameMatchers:d,createReactClassName:f.opts.createReactClassName||"createReactClass"};if(f.opts.plugins){var v=f;var y=f.opts.plugins.map((function(r){var t=typeof r==="string"?r:r[0];if(typeof r!=="string"){v.opts=_objectSpread({},v.opts,r[1])}var a=require(t);if(typeof a!=="function"){a=a.default}return a(e).visitor}));o(p.parent,o.visitors.merge(y),p.scope,v,p.parentPath)}p.traverse({ObjectProperty:{exit:function exit(e){var r=e.node;if(r.computed||r.key.name!=="propTypes"){return}var t=e.findParent((function(e){if(e.type!=="CallExpression"){return false}return e.get("callee").node.name===m.createReactClassName||e.get("callee").node.property&&e.get("callee").node.property.name==="createClass"}));if(t){e.traverse(l);u.add(e);(0,n.default)(e,m,{type:"createClass"})}}},ClassProperty:function ClassProperty(e){var r=e.node,t=e.scope;if(r.key.name==="propTypes"){var a=t.path;if(isReactClass(a.get("superClass"),t,m)){e.traverse(l);u.add(e);(0,n.default)(e,m,{type:"class static",pathClassDeclaration:a})}}},AssignmentExpression:function AssignmentExpression(e){var t=e.node,i=e.scope;if(t.left.computed||!t.left.property||t.left.property.name!=="propTypes"){return}var o=(0,r.default)(e.node.left);if(o){e.traverse(l);u.add(e);(0,n.default)(e,m,{type:"assign"});return}var s=t.left.object.name;var p=i.getBinding(s);if(!p){return}if(p.path.isClassDeclaration()){var f=p.path.get("superClass");if(isReactClass(f,i,m)){e.traverse(l);u.add(e);(0,n.default)(e,m,{type:"assign"})}}else if((0,a.default)(p.path)){e.traverse(l);u.add(e);(0,n.default)(e,m,{type:"assign"})}}});var g=0;var b={VariableDeclarator:function VariableDeclarator(e){if(e.scope.block.type!=="Program"){return}if(["ObjectPattern","ArrayPattern"].includes(e.node.id.type)){return}var r=e.node.id.name;if(!s.has(r)){return}var t=e.scope.getBinding(r),a=t.referencePaths;var i=a.some((function(e){var r=e.find((function(e){return u.has(e)}));return!r}));if(i){g+=1;return}u.add(e);s.delete(r);e.get("init").traverse(l);(0,n.default)(e,m,{type:"declarator"})}};var _=new Set;while(!areSetsEqual(s,_)&&s.size>0&&g<s.size){_=new Set(s);g=0;p.scope.crawl();p.traverse(b)}if(m.removeImport){if(m.mode==="remove"){p.scope.crawl();p.traverse({ImportDeclaration:function ImportDeclaration(e){var r=e.node,t=r.source,a=r.specifiers;var n=m.libraries.some((function(e){if(e instanceof RegExp){return e.test(t.value)}return t.value===e}));if(!n){return}var i=a.some((function(r){var t=r.local.name;var a=e.scope.getBinding(t),n=a.referencePaths;return n.length>0}));if(!i){e.remove()}}})}else{throw new Error('transform-react-remove-prop-type: removeImport = true and mode != "remove" can not be used at the same time.')}}}}}}})();module.exports=t})();
@@ -1,22 +0,0 @@
1
- The MIT License (MIT)
2
-
3
- Copyright (c) 2015 Nikita Gusakov
4
-
5
- Permission is hereby granted, free of charge, to any person obtaining a copy
6
- of this software and associated documentation files (the "Software"), to deal
7
- in the Software without restriction, including without limitation the rights
8
- to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
- copies of the Software, and to permit persons to whom the Software is
10
- furnished to do so, subject to the following conditions:
11
-
12
- The above copyright notice and this permission notice shall be included in all
13
- copies or substantial portions of the Software.
14
-
15
- THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
- IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
- FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
- AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
- LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
- OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
- SOFTWARE.
22
-
@@ -1 +0,0 @@
1
- {"name":"babel-plugin-transform-react-remove-prop-types","author":"Nikita Gusakov","version":"0.4.24","license":"MIT","types":"index.d.ts"}
@@ -1,3 +0,0 @@
1
- import type { RsbuildConfig } from '../types';
2
- export declare const createDefaultConfig: () => RsbuildConfig;
3
- export declare const withDefaultConfig: (config: RsbuildConfig) => RsbuildConfig;
@@ -1,47 +0,0 @@
1
- "use strict";
2
- var __defProp = Object.defineProperty;
3
- var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
- var __getOwnPropNames = Object.getOwnPropertyNames;
5
- var __hasOwnProp = Object.prototype.hasOwnProperty;
6
- var __export = (target, all) => {
7
- for (var name in all)
8
- __defProp(target, name, { get: all[name], enumerable: true });
9
- };
10
- var __copyProps = (to, from, except, desc) => {
11
- if (from && typeof from === "object" || typeof from === "function") {
12
- for (let key of __getOwnPropNames(from))
13
- if (!__hasOwnProp.call(to, key) && key !== except)
14
- __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
15
- }
16
- return to;
17
- };
18
- var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
19
- var defaults_exports = {};
20
- __export(defaults_exports, {
21
- createDefaultConfig: () => createDefaultConfig,
22
- withDefaultConfig: () => withDefaultConfig
23
- });
24
- module.exports = __toCommonJS(defaults_exports);
25
- var import_shared = require("@rsbuild/shared");
26
- const createDefaultConfig = () => ({
27
- dev: (0, import_shared.getDefaultDevConfig)(),
28
- server: (0, import_shared.getDefaultServerConfig)(),
29
- html: (0, import_shared.getDefaultHtmlConfig)(),
30
- tools: {
31
- ...(0, import_shared.getDefaultToolsConfig)(),
32
- cssExtract: {
33
- loaderOptions: {},
34
- pluginOptions: {}
35
- }
36
- },
37
- source: (0, import_shared.getDefaultSourceConfig)(),
38
- output: (0, import_shared.getDefaultOutputConfig)(),
39
- security: (0, import_shared.getDefaultSecurityConfig)(),
40
- performance: (0, import_shared.getDefaultPerformanceConfig)()
41
- });
42
- const withDefaultConfig = (config) => (0, import_shared.mergeRsbuildConfig)(createDefaultConfig(), config);
43
- // Annotate the CommonJS export names for ESM import in node:
44
- 0 && (module.exports = {
45
- createDefaultConfig,
46
- withDefaultConfig
47
- });
@@ -1,7 +0,0 @@
1
- import { RsbuildConfig, NormalizedConfig } from '../types';
2
- /** #__PURE__
3
- * 1. May used by multiple plugins.
4
- * 2. Object value that should not be empty.
5
- * 3. Meaningful and can be filled by constant value.
6
- */
7
- export declare const normalizeConfig: (config: RsbuildConfig) => NormalizedConfig;
@@ -1,33 +0,0 @@
1
- "use strict";
2
- var __defProp = Object.defineProperty;
3
- var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
- var __getOwnPropNames = Object.getOwnPropertyNames;
5
- var __hasOwnProp = Object.prototype.hasOwnProperty;
6
- var __export = (target, all) => {
7
- for (var name in all)
8
- __defProp(target, name, { get: all[name], enumerable: true });
9
- };
10
- var __copyProps = (to, from, except, desc) => {
11
- if (from && typeof from === "object" || typeof from === "function") {
12
- for (let key of __getOwnPropNames(from))
13
- if (!__hasOwnProp.call(to, key) && key !== except)
14
- __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
15
- }
16
- return to;
17
- };
18
- var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
19
- var normalize_exports = {};
20
- __export(normalize_exports, {
21
- normalizeConfig: () => normalizeConfig
22
- });
23
- module.exports = __toCommonJS(normalize_exports);
24
- var import_shared = require("@rsbuild/shared");
25
- var import_defaults = require("./defaults");
26
- const normalizeConfig = (config) => (0, import_shared.mergeRsbuildConfig)(
27
- (0, import_defaults.createDefaultConfig)(),
28
- config
29
- );
30
- // Annotate the CommonJS export names for ESM import in node:
31
- 0 && (module.exports = {
32
- normalizeConfig
33
- });
@@ -1,20 +0,0 @@
1
- import { OnExitFn, OnAfterBuildFn, OnBeforeBuildFn, OnDevCompileDoneFn, ModifyWebpackChainFn, ModifyWebpackConfigFn, ModifyRsbuildConfigFn, OnAfterStartDevServerFn, OnBeforeStartDevServerFn, OnAfterStartProdServerFn, OnBeforeStartProdServerFn, OnAfterCreateCompilerFn, OnBeforeCreateCompilerFn } from '@rsbuild/shared';
2
- import type { ModifyBundlerChainFn } from '@rsbuild/shared';
3
- import type { WebpackConfig, RsbuildConfig } from '../types';
4
- export declare function initHooks(): {
5
- onExitHook: import("@rsbuild/shared").AsyncHook<OnExitFn>;
6
- onAfterBuildHook: import("@rsbuild/shared").AsyncHook<OnAfterBuildFn>;
7
- onBeforeBuildHook: import("@rsbuild/shared").AsyncHook<OnBeforeBuildFn<WebpackConfig>>;
8
- onDevCompileDoneHook: import("@rsbuild/shared").AsyncHook<OnDevCompileDoneFn>;
9
- modifyWebpackChainHook: import("@rsbuild/shared").AsyncHook<ModifyWebpackChainFn>;
10
- modifyWebpackConfigHook: import("@rsbuild/shared").AsyncHook<ModifyWebpackConfigFn>;
11
- modifyRsbuildConfigHook: import("@rsbuild/shared").AsyncHook<ModifyRsbuildConfigFn<RsbuildConfig>>;
12
- onAfterCreateCompilerHook: import("@rsbuild/shared").AsyncHook<OnAfterCreateCompilerFn>;
13
- onBeforeCreateCompilerHook: import("@rsbuild/shared").AsyncHook<OnBeforeCreateCompilerFn<WebpackConfig>>;
14
- onAfterStartDevServerHook: import("@rsbuild/shared").AsyncHook<OnAfterStartDevServerFn>;
15
- onBeforeStartDevServerHook: import("@rsbuild/shared").AsyncHook<OnBeforeStartDevServerFn>;
16
- onAfterStartProdServerHook: import("@rsbuild/shared").AsyncHook<OnAfterStartProdServerFn>;
17
- onBeforeStartProdServerHook: import("@rsbuild/shared").AsyncHook<OnBeforeStartProdServerFn>;
18
- modifyBundlerChainHook: import("@rsbuild/shared").AsyncHook<ModifyBundlerChainFn>;
19
- };
20
- export type Hooks = ReturnType<typeof initHooks>;
@@ -1,46 +0,0 @@
1
- "use strict";
2
- var __defProp = Object.defineProperty;
3
- var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
- var __getOwnPropNames = Object.getOwnPropertyNames;
5
- var __hasOwnProp = Object.prototype.hasOwnProperty;
6
- var __export = (target, all) => {
7
- for (var name in all)
8
- __defProp(target, name, { get: all[name], enumerable: true });
9
- };
10
- var __copyProps = (to, from, except, desc) => {
11
- if (from && typeof from === "object" || typeof from === "function") {
12
- for (let key of __getOwnPropNames(from))
13
- if (!__hasOwnProp.call(to, key) && key !== except)
14
- __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
15
- }
16
- return to;
17
- };
18
- var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
19
- var initHooks_exports = {};
20
- __export(initHooks_exports, {
21
- initHooks: () => initHooks
22
- });
23
- module.exports = __toCommonJS(initHooks_exports);
24
- var import_shared = require("@rsbuild/shared");
25
- function initHooks() {
26
- return {
27
- onExitHook: (0, import_shared.createAsyncHook)(),
28
- onAfterBuildHook: (0, import_shared.createAsyncHook)(),
29
- onBeforeBuildHook: (0, import_shared.createAsyncHook)(),
30
- onDevCompileDoneHook: (0, import_shared.createAsyncHook)(),
31
- modifyWebpackChainHook: (0, import_shared.createAsyncHook)(),
32
- modifyWebpackConfigHook: (0, import_shared.createAsyncHook)(),
33
- modifyRsbuildConfigHook: (0, import_shared.createAsyncHook)(),
34
- onAfterCreateCompilerHook: (0, import_shared.createAsyncHook)(),
35
- onBeforeCreateCompilerHook: (0, import_shared.createAsyncHook)(),
36
- onAfterStartDevServerHook: (0, import_shared.createAsyncHook)(),
37
- onBeforeStartDevServerHook: (0, import_shared.createAsyncHook)(),
38
- onAfterStartProdServerHook: (0, import_shared.createAsyncHook)(),
39
- onBeforeStartProdServerHook: (0, import_shared.createAsyncHook)(),
40
- modifyBundlerChainHook: (0, import_shared.createAsyncHook)()
41
- };
42
- }
43
- // Annotate the CommonJS export names for ESM import in node:
44
- 0 && (module.exports = {
45
- initHooks
46
- });
@@ -1,9 +0,0 @@
1
- import { type PluginStore } from '@rsbuild/shared';
2
- import type { Context, RsbuildPluginAPI } from '../types';
3
- export declare function getPluginAPI({
4
- context,
5
- pluginStore
6
- }: {
7
- context: Context;
8
- pluginStore: PluginStore;
9
- }): RsbuildPluginAPI;
@@ -1,88 +0,0 @@
1
- "use strict";
2
- var __defProp = Object.defineProperty;
3
- var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
- var __getOwnPropNames = Object.getOwnPropertyNames;
5
- var __hasOwnProp = Object.prototype.hasOwnProperty;
6
- var __export = (target, all) => {
7
- for (var name in all)
8
- __defProp(target, name, { get: all[name], enumerable: true });
9
- };
10
- var __copyProps = (to, from, except, desc) => {
11
- if (from && typeof from === "object" || typeof from === "function") {
12
- for (let key of __getOwnPropNames(from))
13
- if (!__hasOwnProp.call(to, key) && key !== except)
14
- __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
15
- }
16
- return to;
17
- };
18
- var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
19
- var initPlugins_exports = {};
20
- __export(initPlugins_exports, {
21
- getPluginAPI: () => getPluginAPI
22
- });
23
- module.exports = __toCommonJS(initPlugins_exports);
24
- var import_shared = require("@rsbuild/shared");
25
- var import_rspack_provider = require("@rsbuild/core/rspack-provider");
26
- function getPluginAPI({
27
- context,
28
- pluginStore
29
- }) {
30
- const { hooks } = context;
31
- const publicContext = (0, import_rspack_provider.createPublicContext)(context);
32
- const getRsbuildConfig = () => {
33
- if (!context.normalizedConfig) {
34
- throw new Error(
35
- "Cannot access Rsbuild config until modifyRsbuildConfig is called."
36
- );
37
- }
38
- return context.config;
39
- };
40
- const getNormalizedConfig = () => {
41
- if (!context.normalizedConfig) {
42
- throw new Error(
43
- "Cannot access normalized config until modifyRsbuildConfig is called."
44
- );
45
- }
46
- return context.normalizedConfig;
47
- };
48
- const getHTMLPaths = () => {
49
- return Object.keys(context.entry).reduce(
50
- (prev, key) => {
51
- prev[key] = (0, import_shared.getHTMLPathByEntry)(key, getNormalizedConfig());
52
- return prev;
53
- },
54
- {}
55
- );
56
- };
57
- (0, import_shared.onExitProcess)(() => {
58
- hooks.onExitHook.call();
59
- });
60
- return {
61
- context: publicContext,
62
- getHTMLPaths,
63
- getRsbuildConfig,
64
- getNormalizedConfig,
65
- isPluginExists: pluginStore.isPluginExists,
66
- // Hooks
67
- onExit: hooks.onExitHook.tap,
68
- onAfterBuild: hooks.onAfterBuildHook.tap,
69
- onBeforeBuild: hooks.onBeforeBuildHook.tap,
70
- onDevCompileDone: hooks.onDevCompileDoneHook.tap,
71
- modifyBundlerChain: hooks.modifyBundlerChainHook.tap,
72
- modifyWebpackChain: hooks.modifyWebpackChainHook.tap,
73
- modifyWebpackConfig: hooks.modifyWebpackConfigHook.tap,
74
- modifyRsbuildConfig: hooks.modifyRsbuildConfigHook.tap,
75
- onAfterCreateCompiler: hooks.onAfterCreateCompilerHook.tap,
76
- onBeforeCreateCompiler: hooks.onBeforeCreateCompilerHook.tap,
77
- onAfterStartDevServer: hooks.onAfterStartDevServerHook.tap,
78
- onBeforeStartDevServer: hooks.onBeforeStartDevServerHook.tap,
79
- onAfterStartProdServer: hooks.onAfterStartProdServerHook.tap,
80
- onBeforeStartProdServer: hooks.onBeforeStartProdServerHook.tap,
81
- modifyRspackConfig: () => {
82
- }
83
- };
84
- }
85
- // Annotate the CommonJS export names for ESM import in node:
86
- 0 && (module.exports = {
87
- getPluginAPI
88
- });
@@ -1,2 +0,0 @@
1
- import type { RsbuildPlugin } from '../types';
2
- export declare const pluginBabel: () => RsbuildPlugin;
@@ -1,157 +0,0 @@
1
- "use strict";
2
- var __create = Object.create;
3
- var __defProp = Object.defineProperty;
4
- var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
5
- var __getOwnPropNames = Object.getOwnPropertyNames;
6
- var __getProtoOf = Object.getPrototypeOf;
7
- var __hasOwnProp = Object.prototype.hasOwnProperty;
8
- var __export = (target, all) => {
9
- for (var name in all)
10
- __defProp(target, name, { get: all[name], enumerable: true });
11
- };
12
- var __copyProps = (to, from, except, desc) => {
13
- if (from && typeof from === "object" || typeof from === "function") {
14
- for (let key of __getOwnPropNames(from))
15
- if (!__hasOwnProp.call(to, key) && key !== except)
16
- __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
17
- }
18
- return to;
19
- };
20
- var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
21
- // If the importer is in node compatibility mode or this is not an ESM
22
- // file that has been converted to a CommonJS file using a Babel-
23
- // compatible transform (i.e. "__esModule" has not been set), then set
24
- // "default" to the CommonJS "module.exports" for node compatibility.
25
- isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
26
- mod
27
- ));
28
- var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
29
- var babel_exports = {};
30
- __export(babel_exports, {
31
- pluginBabel: () => pluginBabel
32
- });
33
- module.exports = __toCommonJS(babel_exports);
34
- var import_lodash = __toESM(require("lodash"));
35
- var import_web = require("@rsbuild/babel-preset/web");
36
- var import_node = require("@rsbuild/babel-preset/node");
37
- var import_shared = require("@rsbuild/shared");
38
- var import_plugin_babel = require("@rsbuild/plugin-babel");
39
- var import_shared2 = require("../shared");
40
- const pluginBabel = () => ({
41
- name: "rsbuild-webpack:babel",
42
- setup(api) {
43
- api.modifyBundlerChain(
44
- async (chain, { CHAIN_ID, target, isProd, isServer, isServiceWorker }) => {
45
- const config = api.getNormalizedConfig();
46
- const browserslist = await (0, import_shared.getBrowserslistWithDefault)(
47
- api.context.rootPath,
48
- config,
49
- target
50
- );
51
- const getBabelOptions = (config2) => {
52
- const includes2 = [];
53
- const excludes2 = [];
54
- const babelUtils = {
55
- addIncludes(items) {
56
- if (Array.isArray(items)) {
57
- includes2.push(...items);
58
- } else {
59
- includes2.push(items);
60
- }
61
- },
62
- addExcludes(items) {
63
- if (Array.isArray(items)) {
64
- excludes2.push(...items);
65
- } else {
66
- excludes2.push(items);
67
- }
68
- }
69
- };
70
- const decoratorConfig = {
71
- version: config2.output.enableLatestDecorators ? "2018-09" : "legacy"
72
- };
73
- const baseBabelConfig = isServer || isServiceWorker ? (0, import_node.getBabelConfigForNode)({
74
- pluginDecorators: decoratorConfig
75
- }) : (0, import_web.getBabelConfigForWeb)({
76
- presetEnv: {
77
- targets: browserslist,
78
- useBuiltIns: (0, import_plugin_babel.getUseBuiltIns)(config2)
79
- },
80
- pluginDecorators: decoratorConfig
81
- });
82
- applyPluginImport(baseBabelConfig, config2.source.transformImport);
83
- applyPluginLodash(
84
- baseBabelConfig,
85
- config2.performance.transformLodash
86
- );
87
- const babelConfig = (0, import_shared.mergeChainedOptions)({
88
- defaults: baseBabelConfig,
89
- options: config2.tools.babel,
90
- utils: {
91
- ...(0, import_plugin_babel.getBabelUtils)(baseBabelConfig),
92
- ...babelUtils
93
- }
94
- });
95
- const finalOptions = {
96
- babelrc: false,
97
- configFile: false,
98
- compact: isProd,
99
- ...babelConfig
100
- };
101
- if (config2.output.charset === "utf8") {
102
- finalOptions.generatorOpts = {
103
- jsescOption: { minimal: true }
104
- };
105
- }
106
- return {
107
- babelOptions: finalOptions,
108
- includes: includes2,
109
- excludes: excludes2
110
- };
111
- };
112
- const { babelOptions, includes, excludes } = getBabelOptions(config);
113
- const rule = chain.module.rule(CHAIN_ID.RULE.JS);
114
- (0, import_shared.applyScriptCondition)({
115
- rule,
116
- config,
117
- context: api.context,
118
- includes,
119
- excludes
120
- });
121
- rule.test(import_shared.SCRIPT_REGEX).use(CHAIN_ID.USE.BABEL).loader(require.resolve("babel-loader")).options(babelOptions);
122
- chain.module.rule(CHAIN_ID.RULE.JS_DATA_URI).mimetype({
123
- or: ["text/javascript", "application/javascript"]
124
- }).use(CHAIN_ID.USE.BABEL).loader(require.resolve("babel-loader")).options(import_lodash.default.cloneDeep(babelOptions));
125
- (0, import_shared.addCoreJsEntry)({ chain, config, isServer, isServiceWorker });
126
- }
127
- );
128
- }
129
- });
130
- function applyPluginLodash(config, transformLodash) {
131
- if (transformLodash) {
132
- config.plugins?.push([(0, import_shared2.getCompiledPath)("babel-plugin-lodash"), {}]);
133
- }
134
- }
135
- function applyPluginImport(config, pluginImport) {
136
- if (pluginImport !== false && pluginImport) {
137
- for (const item of pluginImport) {
138
- const name = item.libraryName;
139
- const option = {
140
- ...item
141
- };
142
- if (option.camelToDashComponentName !== void 0 || option.camel2DashComponentName !== void 0) {
143
- option.camel2DashComponentName = option.camel2DashComponentName ?? option.camelToDashComponentName;
144
- delete option.camelToDashComponentName;
145
- }
146
- config.plugins?.push([
147
- require.resolve("babel-plugin-import"),
148
- option,
149
- name
150
- ]);
151
- }
152
- }
153
- }
154
- // Annotate the CommonJS export names for ESM import in node:
155
- 0 && (module.exports = {
156
- pluginBabel
157
- });
@@ -1,2 +0,0 @@
1
- import type { RsbuildPlugin } from '../types';
2
- export declare const pluginReactWebpack: () => RsbuildPlugin;
@@ -1,103 +0,0 @@
1
- "use strict";
2
- var __create = Object.create;
3
- var __defProp = Object.defineProperty;
4
- var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
5
- var __getOwnPropNames = Object.getOwnPropertyNames;
6
- var __getProtoOf = Object.getPrototypeOf;
7
- var __hasOwnProp = Object.prototype.hasOwnProperty;
8
- var __export = (target, all) => {
9
- for (var name in all)
10
- __defProp(target, name, { get: all[name], enumerable: true });
11
- };
12
- var __copyProps = (to, from, except, desc) => {
13
- if (from && typeof from === "object" || typeof from === "function") {
14
- for (let key of __getOwnPropNames(from))
15
- if (!__hasOwnProp.call(to, key) && key !== except)
16
- __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
17
- }
18
- return to;
19
- };
20
- var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
21
- // If the importer is in node compatibility mode or this is not an ESM
22
- // file that has been converted to a CommonJS file using a Babel-
23
- // compatible transform (i.e. "__esModule" has not been set), then set
24
- // "default" to the CommonJS "module.exports" for node compatibility.
25
- isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
26
- mod
27
- ));
28
- var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
29
- var react_exports = {};
30
- __export(react_exports, {
31
- pluginReactWebpack: () => pluginReactWebpack
32
- });
33
- module.exports = __toCommonJS(react_exports);
34
- var import_plugin_react = require("@rsbuild/plugin-react");
35
- var import_shared = require("@rsbuild/shared");
36
- const pluginReactWebpack = () => ({
37
- name: "rsbuild-webpack:react",
38
- pre: ["rsbuild-webpack:babel"],
39
- setup(api) {
40
- api.modifyRsbuildConfig(async (config, { mergeRsbuildConfig }) => {
41
- const isNewJsx = await (0, import_plugin_react.isBeyondReact17)(api.context.rootPath);
42
- const babelConfig = {
43
- tools: {
44
- babel(_, { addPresets, addPlugins }) {
45
- const presetReactOptions = {
46
- development: !(0, import_shared.isProd)(),
47
- // Will use the native built-in instead of trying to polyfill
48
- useBuiltIns: true,
49
- useSpread: false,
50
- runtime: isNewJsx ? "automatic" : "classic"
51
- };
52
- addPresets([
53
- [require.resolve("@babel/preset-react"), presetReactOptions]
54
- ]);
55
- if ((0, import_shared.isProd)()) {
56
- addPlugins([
57
- [
58
- require.resolve("babel-plugin-transform-react-remove-prop-types"),
59
- { removeImport: true }
60
- ]
61
- ]);
62
- }
63
- }
64
- }
65
- };
66
- return mergeRsbuildConfig(babelConfig, config);
67
- });
68
- api.modifyBundlerChain(async (chain, utils) => {
69
- const config = api.getNormalizedConfig();
70
- if (!(0, import_shared.isUsingHMR)(config, utils)) {
71
- return;
72
- }
73
- const { CHAIN_ID } = utils;
74
- const { default: ReactFastRefreshPlugin } = await Promise.resolve().then(() => __toESM(require("@pmmmwh/react-refresh-webpack-plugin")));
75
- [CHAIN_ID.RULE.TS, CHAIN_ID.RULE.JS].forEach((ruleId) => {
76
- if (!chain.module.rules.get(ruleId)) {
77
- return;
78
- }
79
- const rule = chain.module.rule(ruleId);
80
- if (!rule.uses.get(CHAIN_ID.USE.BABEL)) {
81
- return;
82
- }
83
- rule.use(CHAIN_ID.USE.BABEL).tap((options) => ({
84
- ...options,
85
- plugins: [
86
- ...options.plugins || [],
87
- [require.resolve("react-refresh/babel"), { skipEnvCheck: true }]
88
- ]
89
- }));
90
- });
91
- chain.plugin(CHAIN_ID.PLUGIN.REACT_FAST_REFRESH).use(ReactFastRefreshPlugin, [
92
- {
93
- overlay: false,
94
- exclude: [/node_modules/]
95
- }
96
- ]);
97
- });
98
- }
99
- });
100
- // Annotate the CommonJS export names for ESM import in node:
101
- 0 && (module.exports = {
102
- pluginReactWebpack
103
- });
@@ -1 +0,0 @@
1
- export declare const getCompiledPath: (packageName: string) => string;