Skip to content

Commit

Permalink
fix(babel-plugin): handle "-" at the end of request
Browse files Browse the repository at this point in the history
  • Loading branch information
gregberge committed Mar 20, 2019
1 parent c2650c9 commit c0f325b
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 9 deletions.
16 changes: 8 additions & 8 deletions packages/babel-plugin/src/__snapshots__/index.test.js.snap
Original file line number Diff line number Diff line change
Expand Up @@ -169,7 +169,7 @@ exports[`plugin aggressive import should work with destructuration 1`] = `
chunkName({
foo
}) {
return \`\${foo}\`.replace(/[^a-zA-Z0-9_!§$()=\\\\-^°]+/g, \\"-\\");
return \`\${foo}\`.replace(/[^a-zA-Z0-9_!§$()=\\\\-^°]+/g, \\"-\\").replace(/^-|-$/g, \\"\\");
},
isReady(props) {
Expand Down Expand Up @@ -212,7 +212,7 @@ exports[`plugin aggressive import should work with destructuration 1`] = `
exports[`plugin aggressive import with "webpackChunkName" should replace it 1`] = `
"loadable({
chunkName(props) {
return \`\${props.foo}\`.replace(/[^a-zA-Z0-9_!§$()=\\\\-^°]+/g, \\"-\\");
return \`\${props.foo}\`.replace(/[^a-zA-Z0-9_!§$()=\\\\-^°]+/g, \\"-\\").replace(/^-|-$/g, \\"\\");
},
isReady(props) {
Expand Down Expand Up @@ -251,7 +251,7 @@ exports[`plugin aggressive import with "webpackChunkName" should replace it 1`]
exports[`plugin aggressive import without "webpackChunkName" should support complex request 1`] = `
"loadable({
chunkName(props) {
return \`dir-\${props.foo}-test\`.replace(/[^a-zA-Z0-9_!§$()=\\\\-^°]+/g, \\"-\\");
return \`dir-\${props.foo}-test\`.replace(/[^a-zA-Z0-9_!§$()=\\\\-^°]+/g, \\"-\\").replace(/^-|-$/g, \\"\\");
},
isReady(props) {
Expand Down Expand Up @@ -292,7 +292,7 @@ exports[`plugin aggressive import without "webpackChunkName" should support dest
chunkName({
foo
}) {
return \`dir-\${foo}-test\`.replace(/[^a-zA-Z0-9_!§$()=\\\\-^°]+/g, \\"-\\");
return \`dir-\${foo}-test\`.replace(/[^a-zA-Z0-9_!§$()=\\\\-^°]+/g, \\"-\\").replace(/^-|-$/g, \\"\\");
},
isReady(props) {
Expand Down Expand Up @@ -335,7 +335,7 @@ exports[`plugin aggressive import without "webpackChunkName" should support dest
exports[`plugin aggressive import without "webpackChunkName" should support simple request 1`] = `
"loadable({
chunkName(props) {
return \`\${props.foo}\`.replace(/[^a-zA-Z0-9_!§$()=\\\\-^°]+/g, \\"-\\");
return \`\${props.foo}\`.replace(/[^a-zA-Z0-9_!§$()=\\\\-^°]+/g, \\"-\\").replace(/^-|-$/g, \\"\\");
},
isReady(props) {
Expand Down Expand Up @@ -488,10 +488,10 @@ exports[`plugin simple import should transform path into "chunk-friendly" name 1
});"
`;
exports[`plugin simple import should work with custom name 1`] = `
exports[`plugin simple import should work with * in name 1`] = `
"loadable({
chunkName() {
return \`foo\`.replace(/[^a-zA-Z0-9_$()=\\\\-^°]+/g, \\"-\\");
return \`foo\`.replace(/[^a-zA-Z0-9_$()=\\\\-^°]+/g, \\"-\\").replace(/^-|-$/g, \\"\\");
},
isReady(props) {
Expand Down Expand Up @@ -530,7 +530,7 @@ exports[`plugin simple import should work with custom name 1`] = `
exports[`plugin simple import should work with template literal 1`] = `
"loadable({
chunkName() {
return \`ModA\`.replace(/[^a-zA-Z0-9_$()=\\\\-^°]+/g, \\"-\\");
return \`ModA\`.replace(/[^a-zA-Z0-9_$()=\\\\-^°]+/g, \\"-\\").replace(/^-|-$/g, \\"\\");
},
isReady(props) {
Expand Down
2 changes: 1 addition & 1 deletion packages/babel-plugin/src/index.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ describe('plugin', () => {
expect(result).toMatchSnapshot()
})

it('should work with custom name', () => {
it('should work with * in name', () => {
const result = testPlugin(`
loadable(() => import(\`./foo*\`))
`)
Expand Down

0 comments on commit c0f325b

Please sign in to comment.