@rspack/core 1.4.7-alpha.0 → 1.4.7-alpha.1

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.
@@ -152,9 +152,12 @@ interface JsFormatOptions {
152
152
  * - `false`: removes all comments
153
153
  * - `'some'`: preserves some comments
154
154
  * - `'all'`: preserves all comments
155
+ * - `{ regex: string }`: preserves comments that match the regex
155
156
  * @default false
156
157
  */
157
- comments?: false | "some" | "all";
158
+ comments?: false | "some" | "all" | {
159
+ regex: string;
160
+ };
158
161
  /**
159
162
  * Currently noop.
160
163
  * @default 5
@@ -782,10 +785,6 @@ interface TransformConfig {
782
785
  * https://www.typescriptlang.org/tsconfig#verbatimModuleSyntax
783
786
  */
784
787
  verbatimModuleSyntax?: boolean;
785
- /**
786
- * Native class properties support
787
- */
788
- nativeClassProperties?: boolean;
789
788
  }
790
789
  interface ReactConfig {
791
790
  /**
@@ -1 +1 @@
1
- {"name":"@swc/types","author":"강동윤 <kdy1997.dev@gmail.com>","version":"0.1.22","license":"Apache-2.0","types":"index.d.ts","type":"commonjs"}
1
+ {"name":"@swc/types","author":"강동윤 <kdy1997.dev@gmail.com>","version":"0.1.23","license":"Apache-2.0","types":"index.d.ts","type":"commonjs"}
@@ -82,66 +82,64 @@ let pitch = function(request, _, data) {
82
82
  let options = this.getOptions(), emit = void 0 === options.emit || options.emit, callback = this.async(), filepath = this.resourcePath, parseMeta = this.__internal__parseMeta;
83
83
  this.addDependency(filepath);
84
84
  let { publicPath } = this._compilation.outputOptions;
85
- "string" == typeof options.publicPath ? publicPath = options.publicPath : "function" == typeof options.publicPath && (publicPath = options.publicPath(this.resourcePath, this.rootContext)), "auto" === publicPath && (publicPath = AUTO_PUBLIC_PATH), publicPathForExtract = "string" == typeof publicPath ? /^[a-zA-Z][a-zA-Z\d+\-.]*?:/.test(publicPath) ? publicPath : `${ABSOLUTE_PUBLIC_PATH}${publicPath.replace(/\./g, SINGLE_DOT_PATH_SEGMENT)}` : publicPath;
86
- let handleExports = (originalExports)=>{
87
- let locals, namedExport, esModule = void 0 === options.esModule || options.esModule, dependencies = [];
88
- try {
89
- let exports1 = originalExports.__esModule ? originalExports.default : originalExports;
90
- if (namedExport = originalExports.__esModule && (!originalExports.default || !("locals" in originalExports.default))) for (let key of Object.keys(originalExports))"default" !== key && (locals || (locals = {}), locals[key] = originalExports[key]);
91
- else locals = exports1?.locals;
92
- if (Array.isArray(exports1) && emit) {
93
- let identifierCountMap = new Map();
94
- dependencies = exports1.map(([id, content, media, sourceMap, supports, layer])=>{
95
- let context = this.rootContext, count = identifierCountMap.get(id) || 0;
96
- return identifierCountMap.set(id, count + 1), {
97
- identifier: id,
98
- context,
99
- content,
100
- media,
101
- supports,
102
- layer,
103
- identifierIndex: count,
104
- sourceMap: sourceMap ? JSON.stringify(sourceMap) : void 0,
105
- filepath
106
- };
107
- }).filter((item)=>null !== item);
108
- }
109
- } catch (e) {
110
- callback(e);
111
- return;
112
- }
113
- let result = function() {
114
- if (locals) {
115
- if (namedExport) {
116
- let identifiers = Array.from(function*() {
117
- let identifierId = 0;
118
- for (let key of Object.keys(locals))identifierId += 1, yield [
119
- `_${identifierId.toString(16)}`,
120
- key
121
- ];
122
- }()), localsString = identifiers.map(([id, key])=>{
123
- var value;
124
- return `\nvar ${id} = ${"function" == typeof (value = locals[key]) ? value.toString() : JSON.stringify(value)};`;
125
- }).join(""), exportsString = `export { ${identifiers.map(([id, key])=>`${id} as ${JSON.stringify(key)}`).join(", ")} }`;
126
- return void 0 !== options.defaultExport && options.defaultExport ? `${localsString}\n${exportsString}\nexport default { ${identifiers.map(([id, key])=>`${JSON.stringify(key)}: ${id}`).join(", ")} }\n` : `${localsString}\n${exportsString}\n`;
127
- }
128
- return `\n${esModule ? "export default" : "module.exports = "} ${JSON.stringify(locals)};`;
129
- }
130
- return esModule ? "\nexport {};" : "";
131
- }(), resultSource = `// extracted by ${PLUGIN_NAME}`;
132
- resultSource += this.hot && emit ? hotLoader(result, {
133
- loaderContext: this,
134
- options,
135
- locals: locals
136
- }) : result, dependencies.length > 0 && (parseMeta[PLUGIN_NAME] = JSON.stringify(dependencies)), callback(null, resultSource, void 0, data);
137
- };
138
- this.importModule(`${this.resourcePath}.webpack[javascript/auto]!=!!!${request}`, {
85
+ "string" == typeof options.publicPath ? publicPath = options.publicPath : "function" == typeof options.publicPath && (publicPath = options.publicPath(this.resourcePath, this.rootContext)), "auto" === publicPath && (publicPath = AUTO_PUBLIC_PATH), publicPathForExtract = "string" == typeof publicPath ? /^[a-zA-Z][a-zA-Z\d+\-.]*?:/.test(publicPath) ? publicPath : `${ABSOLUTE_PUBLIC_PATH}${publicPath.replace(/\./g, SINGLE_DOT_PATH_SEGMENT)}` : publicPath, this.importModule(`${this.resourcePath}.webpack[javascript/auto]!=!!!${request}`, {
139
86
  layer: options.layer,
140
87
  publicPath: publicPathForExtract,
141
88
  baseUri: `${BASE_URI}/`
142
89
  }, (error, exports1)=>{
143
90
  if (error) return void callback(error);
144
- handleExports(exports1);
91
+ ((originalExports)=>{
92
+ let locals, namedExport, esModule = void 0 === options.esModule || options.esModule, dependencies = [];
93
+ try {
94
+ let exports1 = originalExports.__esModule ? originalExports.default : originalExports;
95
+ if (namedExport = originalExports.__esModule && (!originalExports.default || !("locals" in originalExports.default))) for (let key of Object.keys(originalExports))"default" !== key && (locals || (locals = {}), locals[key] = originalExports[key]);
96
+ else locals = exports1?.locals;
97
+ if (Array.isArray(exports1) && emit) {
98
+ let identifierCountMap = new Map();
99
+ dependencies = exports1.map(([id, content, media, sourceMap, supports, layer])=>{
100
+ let context = this.rootContext, count = identifierCountMap.get(id) || 0;
101
+ return identifierCountMap.set(id, count + 1), {
102
+ identifier: id,
103
+ context,
104
+ content,
105
+ media,
106
+ supports,
107
+ layer,
108
+ identifierIndex: count,
109
+ sourceMap: sourceMap ? JSON.stringify(sourceMap) : void 0,
110
+ filepath
111
+ };
112
+ }).filter((item)=>null !== item);
113
+ }
114
+ } catch (e) {
115
+ callback(e);
116
+ return;
117
+ }
118
+ let result = function() {
119
+ if (locals) {
120
+ if (namedExport) {
121
+ let identifiers = Array.from(function*() {
122
+ let identifierId = 0;
123
+ for (let key of Object.keys(locals))identifierId += 1, yield [
124
+ `_${identifierId.toString(16)}`,
125
+ key
126
+ ];
127
+ }()), localsString = identifiers.map(([id, key])=>{
128
+ var value;
129
+ return `\nvar ${id} = ${"function" == typeof (value = locals[key]) ? value.toString() : JSON.stringify(value)};`;
130
+ }).join(""), exportsString = `export { ${identifiers.map(([id, key])=>`${id} as ${JSON.stringify(key)}`).join(", ")} }`;
131
+ return void 0 !== options.defaultExport && options.defaultExport ? `${localsString}\n${exportsString}\nexport default { ${identifiers.map(([id, key])=>`${JSON.stringify(key)}: ${id}`).join(", ")} }\n` : `${localsString}\n${exportsString}\n`;
132
+ }
133
+ return `\n${esModule ? "export default" : "module.exports = "} ${JSON.stringify(locals)};`;
134
+ }
135
+ return esModule ? "\nexport {};" : "";
136
+ }(), resultSource = `// extracted by ${PLUGIN_NAME}`;
137
+ resultSource += this.hot && emit ? hotLoader(result, {
138
+ loaderContext: this,
139
+ options,
140
+ locals: locals
141
+ }) : result, dependencies.length > 0 && (parseMeta[PLUGIN_NAME] = JSON.stringify(dependencies)), callback(null, resultSource, void 0, data);
142
+ })(exports1);
145
143
  });
146
144
  }, css_extract_loader = function(content) {
147
145
  if (this._compiler?.options?.experiments?.css && this._module && ("css" === this._module.type || "css/auto" === this._module.type || "css/global" === this._module.type || "css/module" === this._module.type)) return content;