Skip to content

Commit c0f325b

Browse files
committed
fix(babel-plugin): handle "-" at the end of request
1 parent c2650c9 commit c0f325b

File tree

2 files changed

+9
-9
lines changed

2 files changed

+9
-9
lines changed

packages/babel-plugin/src/__snapshots__/index.test.js.snap

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -169,7 +169,7 @@ exports[`plugin aggressive import should work with destructuration 1`] = `
169169
chunkName({
170170
foo
171171
}) {
172-
return \`\${foo}\`.replace(/[^a-zA-Z0-9_!§$()=\\\\-^°]+/g, \\"-\\");
172+
return \`\${foo}\`.replace(/[^a-zA-Z0-9_!§$()=\\\\-^°]+/g, \\"-\\").replace(/^-|-$/g, \\"\\");
173173
},
174174
175175
isReady(props) {
@@ -212,7 +212,7 @@ exports[`plugin aggressive import should work with destructuration 1`] = `
212212
exports[`plugin aggressive import with "webpackChunkName" should replace it 1`] = `
213213
"loadable({
214214
chunkName(props) {
215-
return \`\${props.foo}\`.replace(/[^a-zA-Z0-9_!§$()=\\\\-^°]+/g, \\"-\\");
215+
return \`\${props.foo}\`.replace(/[^a-zA-Z0-9_!§$()=\\\\-^°]+/g, \\"-\\").replace(/^-|-$/g, \\"\\");
216216
},
217217
218218
isReady(props) {
@@ -251,7 +251,7 @@ exports[`plugin aggressive import with "webpackChunkName" should replace it 1`]
251251
exports[`plugin aggressive import without "webpackChunkName" should support complex request 1`] = `
252252
"loadable({
253253
chunkName(props) {
254-
return \`dir-\${props.foo}-test\`.replace(/[^a-zA-Z0-9_!§$()=\\\\-^°]+/g, \\"-\\");
254+
return \`dir-\${props.foo}-test\`.replace(/[^a-zA-Z0-9_!§$()=\\\\-^°]+/g, \\"-\\").replace(/^-|-$/g, \\"\\");
255255
},
256256
257257
isReady(props) {
@@ -292,7 +292,7 @@ exports[`plugin aggressive import without "webpackChunkName" should support dest
292292
chunkName({
293293
foo
294294
}) {
295-
return \`dir-\${foo}-test\`.replace(/[^a-zA-Z0-9_!§$()=\\\\-^°]+/g, \\"-\\");
295+
return \`dir-\${foo}-test\`.replace(/[^a-zA-Z0-9_!§$()=\\\\-^°]+/g, \\"-\\").replace(/^-|-$/g, \\"\\");
296296
},
297297
298298
isReady(props) {
@@ -335,7 +335,7 @@ exports[`plugin aggressive import without "webpackChunkName" should support dest
335335
exports[`plugin aggressive import without "webpackChunkName" should support simple request 1`] = `
336336
"loadable({
337337
chunkName(props) {
338-
return \`\${props.foo}\`.replace(/[^a-zA-Z0-9_!§$()=\\\\-^°]+/g, \\"-\\");
338+
return \`\${props.foo}\`.replace(/[^a-zA-Z0-9_!§$()=\\\\-^°]+/g, \\"-\\").replace(/^-|-$/g, \\"\\");
339339
},
340340
341341
isReady(props) {
@@ -488,10 +488,10 @@ exports[`plugin simple import should transform path into "chunk-friendly" name 1
488488
});"
489489
`;
490490
491-
exports[`plugin simple import should work with custom name 1`] = `
491+
exports[`plugin simple import should work with * in name 1`] = `
492492
"loadable({
493493
chunkName() {
494-
return \`foo\`.replace(/[^a-zA-Z0-9_$()=\\\\-^°]+/g, \\"-\\");
494+
return \`foo\`.replace(/[^a-zA-Z0-9_$()=\\\\-^°]+/g, \\"-\\").replace(/^-|-$/g, \\"\\");
495495
},
496496
497497
isReady(props) {
@@ -530,7 +530,7 @@ exports[`plugin simple import should work with custom name 1`] = `
530530
exports[`plugin simple import should work with template literal 1`] = `
531531
"loadable({
532532
chunkName() {
533-
return \`ModA\`.replace(/[^a-zA-Z0-9_$()=\\\\-^°]+/g, \\"-\\");
533+
return \`ModA\`.replace(/[^a-zA-Z0-9_$()=\\\\-^°]+/g, \\"-\\").replace(/^-|-$/g, \\"\\");
534534
},
535535
536536
isReady(props) {

packages/babel-plugin/src/index.test.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ describe('plugin', () => {
2121
expect(result).toMatchSnapshot()
2222
})
2323

24-
it('should work with custom name', () => {
24+
it('should work with * in name', () => {
2525
const result = testPlugin(`
2626
loadable(() => import(\`./foo*\`))
2727
`)

0 commit comments

Comments
 (0)