Skip to content

Commit

Permalink
fix: allow all characters for webpackChunkName (#6411)
Browse files Browse the repository at this point in the history
  • Loading branch information
xc2 authored Apr 30, 2024
1 parent 8abd18e commit 2e9355e
Show file tree
Hide file tree
Showing 4 changed files with 13 additions and 1 deletion.
2 changes: 1 addition & 1 deletion crates/rspack_plugin_javascript/src/webpack_comment.rs
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@ fn add_magic_comment_warning(
// _5 for true/false
// TODO: regexp/array
static WEBPACK_MAGIC_COMMENT_REGEXP: Lazy<regex::Regex> = Lazy::new(|| {
regex::Regex::new(r#"(?P<_0>webpack[a-zA-Z\d_-]+)\s*:\s*("(?P<_1>(\./)?([\w0-9_\-\[\]\(\)]+/)*?[\w0-9_\-\[\]\(\)]+)"|'(?P<_2>(\./)?([\w0-9_\-\[\]\(\)]+/)*?[\w0-9_\-\[\]\(\)]+)'|`(?P<_3>(\./)?([\w0-9_\-\[\]\(\)]+/)*?[\w0-9_\-\[\]\(\)]+)`|(?P<_4>[\d.-]+)|(?P<_5>true|false))"#)
regex::Regex::new(r#"(?P<_0>webpack[a-zA-Z\d_-]+)\s*:\s*("(?P<_1>[^"]+)"|'(?P<_2>[^']+)'|`(?P<_3>[^`]+)`|(?P<_4>[\d.-]+)|(?P<_5>true|false))"#)
.expect("invalid regex")
});

Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import(/* webpackChunkName: "normal" */ "./normal");
import(/* webpackChunkName: "with.dot" */ "./with_dot");
import(/* webpackChunkName: "./sub/fold" */ "./sub_fold");
import(/* webpackChunkName: './sub/single' */ "./single_quote");

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@ console.log("123");
(self['webpackChunkwebpack'] = self['webpackChunkwebpack'] || []).push([["main"], {
"./index.js": (function (__unused_webpack_module, __unused_webpack_exports, __webpack_require__) {
__webpack_require__.e(/* import() | normal */ "normal").then(__webpack_require__.t.bind(__webpack_require__, "./normal.js", 23));
__webpack_require__.e(/* import() | with.dot */ "with.dot").then(__webpack_require__.t.bind(__webpack_require__, "./with_dot.js", 23));
__webpack_require__.e(/* import() | ./sub/fold */ "./sub/fold").then(__webpack_require__.t.bind(__webpack_require__, "./sub_fold.js", 23));
__webpack_require__.e(/* import() | ./sub/single */ "./sub/single").then(__webpack_require__.t.bind(__webpack_require__, "./single_quote.js", 23));
__webpack_require__.e(/* import() | ./sub/other */ "./sub/other").then(__webpack_require__.t.bind(__webpack_require__, "./other.js", 23));
Expand Down Expand Up @@ -88,5 +89,14 @@ console.log("user (id)/page3");
console.log("user [id]/page2");
}),

}]);
```

```js title=with.dot.js
(self['webpackChunkwebpack'] = self['webpackChunkwebpack'] || []).push([["with.dot"], {
"./with_dot.js": (function () {
console.log("123");
}),

}]);
```
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
console.log("123");

2 comments on commit 2e9355e

@rspack-bot
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

πŸ“ Benchmark detail: Open

task failure

@rspack-bot
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

πŸ“ Ran ecosystem CI: Open

suite result
modernjs, self-hosted, Linux, ci βœ… success
_selftest, ubuntu-latest βœ… success
nx, ubuntu-latest βœ… success
rspress, ubuntu-latest ❌ failure
rsbuild, ubuntu-latest βœ… success
compat, ubuntu-latest βœ… success
examples, ubuntu-latest βœ… success

Please sign in to comment.