Skip to content

Commit 2c68849

Browse files
fix(compiler): support rollup's external input option (#3227)
Pluck the external option from the stencil config and pass it through to rollup. Co-authored-by: Christian Bromann <[email protected]>
1 parent 13db920 commit 2c68849

File tree

4 files changed

+10
-1
lines changed

4 files changed

+10
-1
lines changed

src/compiler/bundle/bundle-output.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -151,6 +151,8 @@ export const getRollupOptions = (
151151
onwarn: createOnWarnFn(buildCtx.diagnostics),
152152

153153
cache: compilerCtx.rollupCache.get(bundleOpts.id),
154+
155+
external: config.rollupConfig.inputOptions.external,
154156
};
155157

156158
return rollupOptions;

src/compiler/config/test/validate-rollup-config.spec.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,7 @@ describe('validateStats', () => {
5656
config.rollupConfig = {
5757
inputOptions: {
5858
context: 'window',
59+
external: 'external_symbol',
5960
notAnOption: {},
6061
},
6162
outputOptions: {
@@ -69,6 +70,7 @@ describe('validateStats', () => {
6970
expect(rollupConfig).toEqual({
7071
inputOptions: {
7172
context: 'window',
73+
external: 'external_symbol',
7274
},
7375
outputOptions: {
7476
globals: {

src/compiler/config/validate-rollup-config.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ export const validateRollupConfig = (config: d.Config): d.RollupConfig => {
2626
if (rollupConfig.inputOptions && isObject(rollupConfig.inputOptions)) {
2727
cleanRollupConfig = {
2828
...cleanRollupConfig,
29-
inputOptions: pluck(rollupConfig.inputOptions, ['context', 'moduleContext', 'treeshake']),
29+
inputOptions: pluck(rollupConfig.inputOptions, ['context', 'moduleContext', 'treeshake', 'external']),
3030
};
3131
}
3232

src/declarations/stencil-public-compiler.ts

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1749,6 +1749,11 @@ export interface RollupInputOptions {
17491749
context?: string;
17501750
moduleContext?: ((id: string) => string) | { [id: string]: string };
17511751
treeshake?: boolean;
1752+
external?:
1753+
| (string | RegExp)[]
1754+
| string
1755+
| RegExp
1756+
| ((source: string, importer: string | undefined, isResolved: boolean) => boolean | null | undefined);
17521757
}
17531758

17541759
export interface RollupOutputOptions {

0 commit comments

Comments
 (0)