Skip to content

Commit

Permalink
fix(compiler): support rollup's external input option (#3227)
Browse files Browse the repository at this point in the history
Pluck the external option from the stencil config and pass it through to rollup.

Co-authored-by: Christian Bromann <[email protected]>
  • Loading branch information
awk and christian-bromann authored Jun 24, 2024
1 parent 13db920 commit 2c68849
Show file tree
Hide file tree
Showing 4 changed files with 10 additions and 1 deletion.
2 changes: 2 additions & 0 deletions src/compiler/bundle/bundle-output.ts
Original file line number Diff line number Diff line change
Expand Up @@ -151,6 +151,8 @@ export const getRollupOptions = (
onwarn: createOnWarnFn(buildCtx.diagnostics),

cache: compilerCtx.rollupCache.get(bundleOpts.id),

external: config.rollupConfig.inputOptions.external,
};

return rollupOptions;
Expand Down
2 changes: 2 additions & 0 deletions src/compiler/config/test/validate-rollup-config.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,7 @@ describe('validateStats', () => {
config.rollupConfig = {
inputOptions: {
context: 'window',
external: 'external_symbol',
notAnOption: {},
},
outputOptions: {
Expand All @@ -69,6 +70,7 @@ describe('validateStats', () => {
expect(rollupConfig).toEqual({
inputOptions: {
context: 'window',
external: 'external_symbol',
},
outputOptions: {
globals: {
Expand Down
2 changes: 1 addition & 1 deletion src/compiler/config/validate-rollup-config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ export const validateRollupConfig = (config: d.Config): d.RollupConfig => {
if (rollupConfig.inputOptions && isObject(rollupConfig.inputOptions)) {
cleanRollupConfig = {
...cleanRollupConfig,
inputOptions: pluck(rollupConfig.inputOptions, ['context', 'moduleContext', 'treeshake']),
inputOptions: pluck(rollupConfig.inputOptions, ['context', 'moduleContext', 'treeshake', 'external']),
};
}

Expand Down
5 changes: 5 additions & 0 deletions src/declarations/stencil-public-compiler.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1749,6 +1749,11 @@ export interface RollupInputOptions {
context?: string;
moduleContext?: ((id: string) => string) | { [id: string]: string };
treeshake?: boolean;
external?:
| (string | RegExp)[]
| string
| RegExp
| ((source: string, importer: string | undefined, isResolved: boolean) => boolean | null | undefined);
}

export interface RollupOutputOptions {
Expand Down

0 comments on commit 2c68849

Please sign in to comment.