File tree Expand file tree Collapse file tree 2 files changed +50
-0
lines changed Expand file tree Collapse file tree 2 files changed +50
-0
lines changed Original file line number Diff line number Diff line change @@ -164,6 +164,31 @@ export default {
164
164
};
165
165
` ` `
166
166
167
+ ### module.parser.javascript.commonjsMagicComments
168
+
169
+ <PropertyType type="boolean" defaultValueList={[{ defaultValue: 'false' }]} />
170
+ <ApiMeta addedVersion="1.5.6" />
171
+
172
+ Enable [Magic comments](/api/runtime-api/module-methods#magic-comments) support for CommonJS.
173
+
174
+ ` ` ` js title= " rspack.config.mjs"
175
+ export default {
176
+ module: {
177
+ parser: {
178
+ javascript: {
179
+ commonjsMagicComments: true ,
180
+ },
181
+ },
182
+ },
183
+ };
184
+ ` ` `
185
+
186
+ Note that only ` webpackIgnore` comment is supported at the moment:
187
+
188
+ ` ` ` js
189
+ const x = require (/* webpackIgnore: true */ ' x' );
190
+ ` ` `
191
+
167
192
### module.parser.javascript.dynamicImportMode
168
193
169
194
<PropertyType
Original file line number Diff line number Diff line change @@ -164,6 +164,31 @@ export default {
164
164
};
165
165
` ` `
166
166
167
+ ### module.parser.javascript.commonjsMagicComments
168
+
169
+ <PropertyType type="boolean" defaultValueList={[{ defaultValue: 'false' }]} />
170
+ <ApiMeta addedVersion="1.5.6" />
171
+
172
+ 为 CommonJS 启用 [Magic comments](/api/runtime-api/module-methods#magic-comments) 支持。
173
+
174
+ ` ` ` js title= " rspack.config.mjs"
175
+ export default {
176
+ module: {
177
+ parser: {
178
+ javascript: {
179
+ commonjsMagicComments: true ,
180
+ },
181
+ },
182
+ },
183
+ };
184
+ ` ` `
185
+
186
+ 目前仅支持 ` webpackIgnore` 注释:
187
+
188
+ ` ` ` js
189
+ const x = require (/* webpackIgnore: true */ ' x' );
190
+ ` ` `
191
+
167
192
### module.parser.javascript.dynamicImportMode
168
193
169
194
<PropertyType
You can’t perform that action at this time.
0 commit comments