Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Only set asset names when finalizing (#4919)
* Only set asset names when finalizing * Improve coverage * Prefer shorter file names over longer file names
- Loading branch information
1 parent
d44fba6
commit 75c5113
Showing
32 changed files
with
284 additions
and
36 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
98 changes: 98 additions & 0 deletions
98
test/chunking-form/samples/asset-needs-code-reference-same-source/_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,98 @@ | ||
const assert = require('node:assert'); | ||
|
||
module.exports = { | ||
description: | ||
'emits unreferenced assets if needsCodeReference is true if they are also emitted without that flag', | ||
options: { | ||
output: { | ||
assetFileNames: '[name][extname]' | ||
}, | ||
plugins: [ | ||
{ | ||
name: 'test', | ||
buildStart() { | ||
this.emitFile({ | ||
type: 'asset', | ||
name: 'needs-reference1.txt', | ||
needsCodeReference: true, | ||
source: 'source1' | ||
}); | ||
this.emitFile({ | ||
type: 'asset', | ||
name: 'file1.txt', | ||
source: 'source1' | ||
}); | ||
this.emitFile({ | ||
type: 'asset', | ||
name: 'file2.txt', | ||
source: 'source2' | ||
}); | ||
this.emitFile({ | ||
type: 'asset', | ||
name: 'needs-reference2.txt', | ||
needsCodeReference: true, | ||
source: 'source2' | ||
}); | ||
this.emitFile({ | ||
type: 'asset', | ||
name: 'needs-reference3.txt', | ||
needsCodeReference: true, | ||
source: 'source3' | ||
}); | ||
this.emitFile({ | ||
type: 'asset', | ||
name: 'file4.txt', | ||
source: 'source4' | ||
}); | ||
this.emitFile({ | ||
type: 'asset', | ||
name: 'needs-reference5.txt', | ||
needsCodeReference: true, | ||
source: 'source5' | ||
}); | ||
this.emitFile({ | ||
type: 'asset', | ||
name: 'file6.txt', | ||
source: 'source6' | ||
}); | ||
}, | ||
renderStart() { | ||
this.emitFile({ | ||
type: 'asset', | ||
name: 'file3.txt', | ||
source: 'source3' | ||
}); | ||
this.emitFile({ | ||
type: 'asset', | ||
name: 'needs-reference4.txt', | ||
needsCodeReference: true, | ||
source: 'source4' | ||
}); | ||
}, | ||
generateBundle(_, bundle) { | ||
this.emitFile({ | ||
type: 'asset', | ||
name: 'file5.txt', | ||
source: 'source5' | ||
}); | ||
this.emitFile({ | ||
type: 'asset', | ||
name: 'needs-reference6.txt', | ||
needsCodeReference: true, | ||
source: 'source6' | ||
}); | ||
|
||
assert.deepEqual(Object.keys(bundle).sort(), [ | ||
'file1.txt', | ||
'file2.txt', | ||
'file4.txt', | ||
'file6.txt', | ||
'main.js', | ||
'needs-reference3.txt', | ||
'needs-reference5.txt' | ||
]); | ||
} | ||
} | ||
] | ||
} | ||
}; |
1 change: 1 addition & 0 deletions
1
test/chunking-form/samples/asset-needs-code-reference-same-source/_expected/amd/file1.txt
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 @@ | ||
source1 |
1 change: 1 addition & 0 deletions
1
test/chunking-form/samples/asset-needs-code-reference-same-source/_expected/amd/file2.txt
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 @@ | ||
source2 |
1 change: 1 addition & 0 deletions
1
test/chunking-form/samples/asset-needs-code-reference-same-source/_expected/amd/file4.txt
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 @@ | ||
source4 |
1 change: 1 addition & 0 deletions
1
test/chunking-form/samples/asset-needs-code-reference-same-source/_expected/amd/file6.txt
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 @@ | ||
source6 |
5 changes: 5 additions & 0 deletions
5
test/chunking-form/samples/asset-needs-code-reference-same-source/_expected/amd/main.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('main'); | ||
|
||
})); |
1 change: 1 addition & 0 deletions
1
...ng-form/samples/asset-needs-code-reference-same-source/_expected/amd/needs-reference3.txt
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 @@ | ||
source3 |
1 change: 1 addition & 0 deletions
1
...ng-form/samples/asset-needs-code-reference-same-source/_expected/amd/needs-reference5.txt
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 @@ | ||
source5 |
1 change: 1 addition & 0 deletions
1
test/chunking-form/samples/asset-needs-code-reference-same-source/_expected/cjs/file1.txt
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 @@ | ||
source1 |
1 change: 1 addition & 0 deletions
1
test/chunking-form/samples/asset-needs-code-reference-same-source/_expected/cjs/file2.txt
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 @@ | ||
source2 |
1 change: 1 addition & 0 deletions
1
test/chunking-form/samples/asset-needs-code-reference-same-source/_expected/cjs/file4.txt
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 @@ | ||
source4 |
1 change: 1 addition & 0 deletions
1
test/chunking-form/samples/asset-needs-code-reference-same-source/_expected/cjs/file6.txt
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 @@ | ||
source6 |
3 changes: 3 additions & 0 deletions
3
test/chunking-form/samples/asset-needs-code-reference-same-source/_expected/cjs/main.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('main'); |
1 change: 1 addition & 0 deletions
1
...ng-form/samples/asset-needs-code-reference-same-source/_expected/cjs/needs-reference3.txt
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 @@ | ||
source3 |
1 change: 1 addition & 0 deletions
1
...ng-form/samples/asset-needs-code-reference-same-source/_expected/cjs/needs-reference5.txt
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 @@ | ||
source5 |
1 change: 1 addition & 0 deletions
1
test/chunking-form/samples/asset-needs-code-reference-same-source/_expected/es/file1.txt
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 @@ | ||
source1 |
1 change: 1 addition & 0 deletions
1
test/chunking-form/samples/asset-needs-code-reference-same-source/_expected/es/file2.txt
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 @@ | ||
source2 |
1 change: 1 addition & 0 deletions
1
test/chunking-form/samples/asset-needs-code-reference-same-source/_expected/es/file4.txt
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 @@ | ||
source4 |
1 change: 1 addition & 0 deletions
1
test/chunking-form/samples/asset-needs-code-reference-same-source/_expected/es/file6.txt
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 @@ | ||
source6 |
1 change: 1 addition & 0 deletions
1
test/chunking-form/samples/asset-needs-code-reference-same-source/_expected/es/main.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('main'); |
1 change: 1 addition & 0 deletions
1
...ing-form/samples/asset-needs-code-reference-same-source/_expected/es/needs-reference3.txt
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 @@ | ||
source3 |
1 change: 1 addition & 0 deletions
1
...ing-form/samples/asset-needs-code-reference-same-source/_expected/es/needs-reference5.txt
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 @@ | ||
source5 |
1 change: 1 addition & 0 deletions
1
test/chunking-form/samples/asset-needs-code-reference-same-source/_expected/system/file1.txt
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 @@ | ||
source1 |
1 change: 1 addition & 0 deletions
1
test/chunking-form/samples/asset-needs-code-reference-same-source/_expected/system/file2.txt
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 @@ | ||
source2 |
1 change: 1 addition & 0 deletions
1
test/chunking-form/samples/asset-needs-code-reference-same-source/_expected/system/file4.txt
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 @@ | ||
source4 |
1 change: 1 addition & 0 deletions
1
test/chunking-form/samples/asset-needs-code-reference-same-source/_expected/system/file6.txt
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 @@ | ||
source6 |
Oops, something went wrong.