Skip to content

Commit 8435748

Browse files
committed
feat(compiler): deprecate customResolveOptions config option
deprecate the `nodeResolve#customResolveOptions` configuration option in a Stencil configuration. this field is used to configure `@rollup/plugin-node-resolve` when generating any non-documentation output target artifacts. the contents of this option get propagated by the rollup plugin to `resolve`, which does the actual resolution of files in stencil's in-memory filesystem. in newer versions of `@rollup/plugin-node-resolve`, this option has been removed, which no option to override defaults (creating a separation of concerns between the plugin and `resolve`). since stencil exposes this configuration in its public api, we cannot remove it without causing a breaking change (nor could we find a suitable way to reuse an existing configuration). this change is a prerequisite to upgrading `@rollup/plugin-node-resolve`. we will not remove the configuration option/upgrade the plugin until stencil v5. in the interim, we add a warning message at config validation time to try to elicit feedback on this change STENCIL-595: Update Rollup v2.X Infrastructure
1 parent 0d61a53 commit 8435748

File tree

4 files changed

+35
-2
lines changed

4 files changed

+35
-2
lines changed

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

+19-1
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,24 @@ describe('validateCustom', () => {
2626
},
2727
];
2828
const { diagnostics } = validateConfig(userConfig, mockLoadConfigInit());
29-
expect(diagnostics.length).toBe(1);
29+
// TODO(STENCIL-1107): Decrement the right-hand side value from 2 to 1
30+
expect(diagnostics.length).toBe(2);
31+
// TODO(STENCIL-1107): Keep this assertion
32+
expect(diagnostics[0]).toEqual({
33+
header: 'Build Warn',
34+
level: 'warn',
35+
lines: [],
36+
messageText: 'test warning',
37+
type: 'build',
38+
});
39+
// TODO(STENCIL-1107): Remove this assertion
40+
expect(diagnostics[1]).toEqual({
41+
header: 'Build Warn',
42+
level: 'warn',
43+
lines: [],
44+
messageText:
45+
'nodeResolve.customResolveOptions is a deprecated option in a Stencil Configuration file. If you need this option, please open a new issue in the Stencil repository (https://github.com/ionic-team/stencil/issues/new/choose)',
46+
type: 'build',
47+
});
3048
});
3149
});

src/compiler/config/validate-config.ts

+10-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import { createNodeLogger, createNodeSys } from '@sys-api-node';
2-
import { buildError, isBoolean, isNumber, isString, sortBy } from '@utils';
2+
import { buildError, buildWarn, isBoolean, isNumber, isString, sortBy } from '@utils';
33

44
import {
55
ConfigBundle,
@@ -265,6 +265,15 @@ export const validateConfig = (
265265
return arr;
266266
}, [] as RegExp[]);
267267

268+
// TODO(STENCIL-1107): Remove this check. It'll be unneeded (and raise a compilation error when we build Stencil) once
269+
// this property is removed.
270+
if (validatedConfig.nodeResolve?.customResolveOptions) {
271+
const warn = buildWarn(diagnostics);
272+
// this message is particularly long - let the underlying logger implementation take responsibility for breaking it
273+
// up to fit in a terminal window
274+
warn.messageText = `nodeResolve.customResolveOptions is a deprecated option in a Stencil Configuration file. If you need this option, please open a new issue in the Stencil repository (https://github.com/ionic-team/stencil/issues/new/choose)`;
275+
}
276+
268277
CACHED_VALIDATED_CONFIG = validatedConfig;
269278

270279
return {

src/declarations/stencil-public-compiler.ts

+4
Original file line numberDiff line numberDiff line change
@@ -1613,8 +1613,12 @@ export interface NodeResolveConfig {
16131613
only?: Array<string | RegExp>;
16141614
modulesOnly?: boolean;
16151615

1616+
// TODO(STENCIL-1107): Remove this field [BREAKING_CHANGE]
16161617
/**
16171618
* @see https://github.com/browserify/resolve#resolveid-opts-cb
1619+
* @deprecated the `customResolveOptions` field is no longer honored in future versions of
1620+
* `@rollup/plugin-node-resolve`. If you are currently using it, please open a new issue in the Stencil repo to
1621+
* describe your use case & provide input (https://github.com/ionic-team/stencil/issues/new/choose)
16181622
*/
16191623
customResolveOptions?: {
16201624
basedir?: string;

src/testing/mocks.ts

+2
Original file line numberDiff line numberDiff line change
@@ -99,6 +99,8 @@ export function mockConfig(overrides: Partial<UnvalidatedConfig> = {}): Unvalida
9999
minifyJs: false,
100100
namespace: 'Testing',
101101
nodeResolve: {
102+
// TODO(STENCIL-1107): Remove this field - it's currently overriding Stencil's default options to pass into
103+
// the `@rollup/plugin-node-resolve` plugin.
102104
customResolveOptions: {},
103105
},
104106
outputTargets: null,

0 commit comments

Comments
 (0)