Skip to content

Commit 643406c

Browse files
authored
Merge pull request #40 from schlusslicht/feat/config-external
[FEAT] Override externals
2 parents 5b4acd3 + 635ccde commit 643406c

File tree

3 files changed

+7
-0
lines changed

3 files changed

+7
-0
lines changed

README.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -61,6 +61,9 @@ webWorkerLoader({
6161
forceInline?: boolean, // *EXPERIMENTAL* when inlined, forces the code to be included every time it is imported
6262
// useful when using code splitting: Default: false
6363

64+
external?: string[], // *EXPERIMENTAL* override rollup resolution of external module IDs
65+
// useful to inline external dependencies in a worker blob. Default: undefined
66+
6467
preserveSource?: boolean, // When inlined and this option is enabled, the full source code is included in the
6568
// built file, otherwise it's embedded as a base64 string. Default: false
6669

src/index.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ const defaultConfig = {
1414
pattern: /web-worker:(.+)/,
1515
inline: true,
1616
forceInline: false,
17+
external: undefined,
1718
extensions: [ '.js' ],
1819
outputFolder: '',
1920
skipPlugins: [

src/plugin/load.js

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -75,6 +75,9 @@ function load(state, config, addWatchFile, id) {
7575
const {inputOptions, workerID, target} = state.idMap.get(id);
7676
state.exclude.add(id);
7777
state.exclude.add(target);
78+
if (config.external) {
79+
inputOptions.external = config.external;
80+
}
7881
rollup.rollup(inputOptions).then(bundle => {
7982
state.exclude.delete(id);
8083
state.exclude.delete(target);

0 commit comments

Comments
 (0)