Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add referenced files to bundle (#3661)
* Add referenced files to bundle * Store plugin driver on class
- Loading branch information
1 parent
19e50af
commit ed1bd33
Showing
12 changed files
with
111 additions
and
67 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
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
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
1 change: 0 additions & 1 deletion
1
test/function/samples/emit-file/emit-from-output-options/buildStart1.js
This file was deleted.
Oops, something went wrong.
1 change: 0 additions & 1 deletion
1
test/function/samples/emit-file/emit-from-output-options/buildStart2.js
This file was deleted.
Oops, something went wrong.
39 changes: 39 additions & 0 deletions
39
test/function/samples/emit-file/file-references-in-bundle/_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,39 @@ | ||
const assert = require('assert'); | ||
|
||
module.exports = { | ||
description: 'lists referenced files in the bundle', | ||
options: { | ||
input: 'main', | ||
plugins: { | ||
transform() { | ||
return `export const asset = import.meta.ROLLUP_FILE_URL_${this.emitFile({ | ||
type: 'asset', | ||
name: 'asset.txt', | ||
source: 'asset' | ||
})};\nexport const chunk = import.meta.ROLLUP_FILE_URL_${this.emitFile({ | ||
type: 'chunk', | ||
id: 'ref.js' | ||
})}`; | ||
}, | ||
generateBundle(options, bundle) { | ||
assert.deepStrictEqual(bundle['main.js'].referencedFiles, [ | ||
'assets/asset.txt', | ||
'chunks/ref.js' | ||
]); | ||
} | ||
}, | ||
output: { | ||
assetFileNames: 'assets/[name][extname]', | ||
chunkFileNames: 'chunks/[name].js' | ||
} | ||
}, | ||
context: { | ||
__dirname: 'dir' | ||
}, | ||
exports(exports) { | ||
assert.deepStrictEqual(exports, { | ||
asset: 'file:///dir/assets/asset.txt', | ||
chunk: 'file:///dir/chunks/ref.js' | ||
}); | ||
} | ||
}; |
1 change: 1 addition & 0 deletions
1
test/function/samples/emit-file/file-references-in-bundle/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 @@ | ||
throw new Error('not executed'); |
1 change: 1 addition & 0 deletions
1
test/function/samples/emit-file/file-references-in-bundle/ref.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('Hello'); |
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