Skip to content

Commit 34d2284

Browse files
johnjenkinsJohn Jenkins
and
John Jenkins
authored
build: improve nodeResolve config (#6203)
* fix(build): expand nodeResolve export conditions to include `require` * chore: nodeResolve - allow user config to take precedence over default. Update types * chore: tweak * chore: untweak :D --------- Co-authored-by: John Jenkins <[email protected]>
1 parent bf5a470 commit 34d2284

File tree

2 files changed

+13
-8
lines changed

2 files changed

+13
-8
lines changed

src/compiler/bundle/bundle-output.ts

+3-2
Original file line numberDiff line numberDiff line change
@@ -59,10 +59,11 @@ export const getRollupOptions = (
5959
): RollupOptions => {
6060
const nodeResolvePlugin = rollupNodeResolvePlugin({
6161
mainFields: ['collection:main', 'jsnext:main', 'es2017', 'es2015', 'module', 'main'],
62-
browser: true,
62+
browser: bundleOpts.platform !== 'hydrate',
6363
rootDir: config.rootDir,
64-
...(config.nodeResolve as any),
64+
exportConditions: ['default', 'module', 'import', 'require'],
6565
extensions: ['.tsx', '.ts', '.mts', '.cts', '.js', '.mjs', '.cjs', '.json', '.d.ts', '.d.mts', '.d.cts'],
66+
...config.nodeResolve,
6667
});
6768

6869
// @ts-expect-error - this is required now.

src/declarations/stencil-public-compiler.ts

+10-6
Original file line numberDiff line numberDiff line change
@@ -1772,15 +1772,19 @@ export interface BundlingConfig {
17721772
}
17731773

17741774
export interface NodeResolveConfig {
1775-
module?: boolean;
1776-
jsnext?: boolean;
1777-
main?: boolean;
1775+
exportConditions?: string[];
17781776
browser?: boolean;
1779-
extensions?: string[];
1780-
preferBuiltins?: boolean;
1777+
moduleDirectories?: string[];
1778+
modulePaths?: string[];
1779+
dedupe?: string[] | ((importee: string) => boolean);
1780+
extensions?: readonly string[];
17811781
jail?: string;
1782-
only?: Array<string | RegExp>;
1782+
mainFields?: readonly string[];
17831783
modulesOnly?: boolean;
1784+
preferBuiltins?: boolean | ((module: string) => boolean);
1785+
resolveOnly?: ReadonlyArray<string | RegExp> | null | ((module: string) => boolean);
1786+
rootDir?: string;
1787+
allowExportsFolderMapping?: boolean;
17841788

17851789
// TODO(STENCIL-1107): Remove this field [BREAKING_CHANGE]
17861790
/**

0 commit comments

Comments
 (0)