Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Ignore queries and hashes in file names when preserving modules (#4374)
- Loading branch information
1 parent
e0b1060
commit f420a01
Showing
51 changed files
with
93 additions
and
37 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,12 +1,13 @@ | ||
// https://datatracker.ietf.org/doc/html/rfc2396 | ||
// eslint-disable-next-line no-control-regex | ||
const INVALID_CHAR_RE = /[\x00-\x1F\x7F<>*#"{}|^[\]`;?:&=+$,]/g; | ||
const INVALID_CHAR_REGEX = /[\x00-\x1F\x7F<>*#"{}|^[\]`;?:&=+$,]/g; | ||
const DRIVE_LETTER_REGEX = /^[a-z]:/i; | ||
|
||
export function sanitizeFileName(name: string): string { | ||
const match = /^[a-z]:/i.exec(name); | ||
const match = DRIVE_LETTER_REGEX.exec(name); | ||
const driveLetter = match ? match[0] : ''; | ||
|
||
// A `:` is only allowed as part of a windows drive letter (ex: C:\foo) | ||
// Otherwise, avoid them because they can refer to NTFS alternate data streams. | ||
return driveLetter + name.substr(driveLetter.length).replace(INVALID_CHAR_RE, '_'); | ||
return driveLetter + name.substr(driveLetter.length).replace(INVALID_CHAR_REGEX, '_'); | ||
} |
File renamed without changes.
2 changes: 1 addition & 1 deletion
2
test/chunking-form/samples/deprecated/preserve-modules-commonjs/_expected/amd/commonjs.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
2 changes: 1 addition & 1 deletion
2
test/chunking-form/samples/deprecated/preserve-modules-commonjs/_expected/amd/other.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
2 changes: 1 addition & 1 deletion
2
test/chunking-form/samples/deprecated/preserve-modules-commonjs/_expected/cjs/other.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes.
2 changes: 1 addition & 1 deletion
2
test/chunking-form/samples/deprecated/preserve-modules-commonjs/_expected/es/commonjs.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
4 changes: 2 additions & 2 deletions
4
test/chunking-form/samples/deprecated/preserve-modules-commonjs/_expected/es/other.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,4 @@ | ||
import { __exports as other } from './_virtual/other.js_commonjs-exports.js'; | ||
export { __exports as default } from './_virtual/other.js_commonjs-exports.js'; | ||
import { __exports as other } from './_virtual/other.js'; | ||
export { __exports as default } from './_virtual/other.js'; | ||
|
||
other.value = 43; |
File renamed without changes.
2 changes: 1 addition & 1 deletion
2
test/chunking-form/samples/deprecated/preserve-modules-commonjs/_expected/system/commonjs.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
2 changes: 1 addition & 1 deletion
2
test/chunking-form/samples/deprecated/preserve-modules-commonjs/_expected/system/other.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
15 changes: 15 additions & 0 deletions
15
test/chunking-form/samples/ignore-chunk-name-query/_config.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
const { loader } = require('../../../utils.js'); | ||
|
||
module.exports = { | ||
description: 'ignores queries and hashes for chunk names when preserving modules', | ||
options: { | ||
input: ['a.js?query', 'b.js#hash'], | ||
output: { preserveModules: true }, | ||
plugins: [ | ||
loader({ | ||
'a.js?query': "console.log('a');", | ||
'b.js#hash': "console.log('b');" | ||
}) | ||
] | ||
} | ||
}; |
5 changes: 5 additions & 0 deletions
5
test/chunking-form/samples/ignore-chunk-name-query/_expected/amd/_virtual/a.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
define((function () { 'use strict'; | ||
|
||
console.log('a'); | ||
|
||
})); |
5 changes: 5 additions & 0 deletions
5
test/chunking-form/samples/ignore-chunk-name-query/_expected/amd/_virtual/b.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
define((function () { 'use strict'; | ||
|
||
console.log('b'); | ||
|
||
})); |
3 changes: 3 additions & 0 deletions
3
test/chunking-form/samples/ignore-chunk-name-query/_expected/cjs/_virtual/a.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
'use strict'; | ||
|
||
console.log('a'); |
3 changes: 3 additions & 0 deletions
3
test/chunking-form/samples/ignore-chunk-name-query/_expected/cjs/_virtual/b.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
'use strict'; | ||
|
||
console.log('b'); |
1 change: 1 addition & 0 deletions
1
test/chunking-form/samples/ignore-chunk-name-query/_expected/es/_virtual/a.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
console.log('a'); |
1 change: 1 addition & 0 deletions
1
test/chunking-form/samples/ignore-chunk-name-query/_expected/es/_virtual/b.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
console.log('b'); |
10 changes: 10 additions & 0 deletions
10
test/chunking-form/samples/ignore-chunk-name-query/_expected/system/_virtual/a.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
System.register([], (function () { | ||
'use strict'; | ||
return { | ||
execute: (function () { | ||
|
||
console.log('a'); | ||
|
||
}) | ||
}; | ||
})); |
10 changes: 10 additions & 0 deletions
10
test/chunking-form/samples/ignore-chunk-name-query/_expected/system/_virtual/b.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
System.register([], (function () { | ||
'use strict'; | ||
return { | ||
execute: (function () { | ||
|
||
console.log('b'); | ||
|
||
}) | ||
}; | ||
})); |
File renamed without changes.
2 changes: 1 addition & 1 deletion
2
test/chunking-form/samples/preserve-modules-commonjs/_expected/amd/commonjs.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
2 changes: 1 addition & 1 deletion
2
test/chunking-form/samples/preserve-modules-commonjs/_expected/amd/other.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
2 changes: 1 addition & 1 deletion
2
test/chunking-form/samples/preserve-modules-commonjs/_expected/cjs/other.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes.
2 changes: 1 addition & 1 deletion
2
test/chunking-form/samples/preserve-modules-commonjs/_expected/es/commonjs.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
4 changes: 2 additions & 2 deletions
4
test/chunking-form/samples/preserve-modules-commonjs/_expected/es/other.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,4 @@ | ||
import { __exports as other } from './_virtual/other.js_commonjs-exports.js'; | ||
export { __exports as default } from './_virtual/other.js_commonjs-exports.js'; | ||
import { __exports as other } from './_virtual/other.js'; | ||
export { __exports as default } from './_virtual/other.js'; | ||
|
||
other.value = 43; |
File renamed without changes.
2 changes: 1 addition & 1 deletion
2
test/chunking-form/samples/preserve-modules-commonjs/_expected/system/commonjs.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
2 changes: 1 addition & 1 deletion
2
test/chunking-form/samples/preserve-modules-commonjs/_expected/system/other.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes.
2 changes: 1 addition & 1 deletion
2
test/chunking-form/samples/preserve-modules-root/_expected/amd/below/module.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
2 changes: 1 addition & 1 deletion
2
...samples/preserve-modules-root/_expected/amd/custom_modules/@my-scope/my-base-pkg/index.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
2 changes: 1 addition & 1 deletion
2
test/chunking-form/samples/preserve-modules-root/_expected/amd/under-build.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes.
2 changes: 1 addition & 1 deletion
2
test/chunking-form/samples/preserve-modules-root/_expected/cjs/below/module.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
2 changes: 1 addition & 1 deletion
2
...samples/preserve-modules-root/_expected/cjs/custom_modules/@my-scope/my-base-pkg/index.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
2 changes: 1 addition & 1 deletion
2
test/chunking-form/samples/preserve-modules-root/_expected/cjs/under-build.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes.
2 changes: 1 addition & 1 deletion
2
test/chunking-form/samples/preserve-modules-root/_expected/es/below/module.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
4 changes: 2 additions & 2 deletions
4
.../samples/preserve-modules-root/_expected/es/custom_modules/@my-scope/my-base-pkg/index.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
2 changes: 1 addition & 1 deletion
2
test/chunking-form/samples/preserve-modules-root/_expected/es/under-build.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes.
2 changes: 1 addition & 1 deletion
2
test/chunking-form/samples/preserve-modules-root/_expected/system/below/module.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
2 changes: 1 addition & 1 deletion
2
...ples/preserve-modules-root/_expected/system/custom_modules/@my-scope/my-base-pkg/index.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
2 changes: 1 addition & 1 deletion
2
test/chunking-form/samples/preserve-modules-root/_expected/system/under-build.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters