Skip to content

Commit d54c44c

Browse files
johnjenkinsJohn Jenkins
and
John Jenkins
authored
build: update rollup to latest (#6187)
* chore: upgrade rollup. WIP. * chore: tidying * chore: add optional rollup linux package * chore: fix type --------- Co-authored-by: John Jenkins <john.jenkins@nanoporetech.com>
1 parent 840ead9 commit d54c44c

File tree

18 files changed

+386
-245
lines changed

18 files changed

+386
-245
lines changed

package-lock.json

+347-208
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

+11-7
Original file line numberDiff line numberDiff line change
@@ -128,11 +128,12 @@
128128
},
129129
"devDependencies": {
130130
"@ionic/prettier-config": "^4.0.0",
131-
"@rollup/plugin-commonjs": "21.1.0",
131+
"@jridgewell/source-map": "^0.3.6",
132+
"@rollup/plugin-commonjs": "28.0.2",
132133
"@rollup/plugin-json": "6.1.0",
133-
"@rollup/plugin-node-resolve": "9.0.0",
134-
"@rollup/plugin-replace": "5.0.7",
135-
"@rollup/pluginutils": "5.1.3",
134+
"@rollup/plugin-node-resolve": "16.0.0",
135+
"@rollup/plugin-replace": "6.0.2",
136+
"@rollup/pluginutils": "5.1.4",
136137
"@types/eslint": "^8.4.6",
137138
"@types/exit": "^0.1.31",
138139
"@types/fs-extra": "^11.0.0",
@@ -179,21 +180,24 @@
179180
"node-fetch": "3.3.2",
180181
"open": "^9.0.0",
181182
"open-in-editor": "2.2.0",
182-
"parse5": "7.1.2",
183+
"parse5": "7.2.1",
183184
"pixelmatch": "5.3.0",
184185
"postcss": "^8.2.8",
185186
"prettier": "3.3.1",
186187
"prompts": "2.4.2",
187188
"puppeteer": "^24.1.0",
188189
"rimraf": "^6.0.1",
189-
"rollup": "2.56.3",
190+
"rollup": "4.34.9",
190191
"semver": "^7.3.7",
191-
"terser": "5.31.1",
192+
"terser": "5.37.0",
192193
"tsx": "^4.19.2",
193194
"typescript": "~5.5.4",
194195
"webpack": "^5.75.0",
195196
"ws": "8.17.1"
196197
},
198+
"optionalDependencies": {
199+
"@rollup/rollup-linux-x64-gnu": "4.34.9"
200+
},
197201
"engines": {
198202
"node": ">=16.0.0",
199203
"npm": ">=7.10.0"

scripts/esbuild/utils/parse5.ts

-1
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,6 @@ export async function bundleParse5(opts: BuildOptions): Promise<[contents: strin
6060
format: 'iife',
6161
name: 'PARSE5',
6262
footer: ['export const parse = PARSE5.parse;', 'export const parseFragment = PARSE5.parseFragment;'].join('\n'),
63-
preferConst: true,
6463
strict: false,
6564
});
6665

scripts/esbuild/utils/terser.ts

-1
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,6 @@ export async function bundleTerser(opts: BuildOptions): Promise<[content: string
3030

3131
const { output } = await rollupBuild.generate({
3232
format: 'es',
33-
preferConst: true,
3433
strict: false,
3534
});
3635

src/compiler/app-core/bundle-app-core.ts

+4-1
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,10 @@ export const generateRollupOutput = async (
3030
return {
3131
type: 'chunk',
3232
fileName: chunk.fileName,
33-
map: chunk.map,
33+
map: {
34+
...chunk.map,
35+
sourcesContent: chunk.map?.sourcesContent || [],
36+
},
3437
code: chunk.code,
3538
moduleFormat: options.format,
3639
entryKey: chunk.name,

src/compiler/bundle/bundle-output.ts

+10-12
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,6 @@ import { PluginContext, rollup, RollupOptions, TreeshakingOptions } from 'rollup
77

88
import type * as d from '../../declarations';
99
import { lazyComponentPlugin } from '../output-targets/dist-lazy/lazy-component-plugin';
10-
import { createCustomResolverAsync } from '../sys/resolve/resolve-module-async';
1110
import { appDataPlugin } from './app-data-plugin';
1211
import type { BundleOptions } from './bundle-interface';
1312
import { coreResolvePlugin } from './core-resolve-plugin';
@@ -58,25 +57,24 @@ export const getRollupOptions = (
5857
buildCtx: d.BuildCtx,
5958
bundleOpts: BundleOptions,
6059
): RollupOptions => {
61-
const customResolveOptions = createCustomResolverAsync(config.sys, compilerCtx.fs, [
62-
'.tsx',
63-
'.ts',
64-
'.js',
65-
'.mjs',
66-
'.json',
67-
'.d.ts',
68-
]);
6960
const nodeResolvePlugin = rollupNodeResolvePlugin({
7061
mainFields: ['collection:main', 'jsnext:main', 'es2017', 'es2015', 'module', 'main'],
71-
customResolveOptions,
7262
browser: true,
7363
rootDir: config.rootDir,
7464
...(config.nodeResolve as any),
65+
extensions: ['.tsx', '.ts', '.js', '.mjs', '.json', '.d.ts'],
7566
});
7667

77-
const orgNodeResolveId = nodeResolvePlugin.resolveId;
78-
const orgNodeResolveId2 = (nodeResolvePlugin.resolveId = async function (importee: string, importer: string) {
68+
// @ts-expect-error - this is required now.
69+
nodeResolvePlugin.resolve = async function () {
70+
// Investigate if we can use this to leverage Stencil's in-memory fs
71+
};
72+
// @ts-expect-error - handler is defined
73+
const orgNodeResolveId = nodeResolvePlugin.resolveId.handler;
74+
// @ts-expect-error - handler is defined
75+
const orgNodeResolveId2 = (nodeResolvePlugin.resolveId.handler = async function (importee: string, importer: string) {
7976
const [realImportee, query] = importee.split('?');
77+
// @ts-ignore
8078
const resolved = await orgNodeResolveId.call(
8179
nodeResolvePlugin as unknown as PluginContext,
8280
realImportee,

src/compiler/bundle/worker-plugin.ts

-1
Original file line numberDiff line numberDiff line change
@@ -186,7 +186,6 @@ const buildWorker = async (
186186
footer: '})();',
187187
intro: getWorkerIntro(workerMsgId, config.devMode),
188188
esModule: false,
189-
preferConst: true,
190189
externalLiveBindings: false,
191190
});
192191
const entryPoint = output.output[0];

src/compiler/output-targets/dist-custom-elements/index.ts

-1
Original file line numberDiff line numberDiff line change
@@ -123,7 +123,6 @@ export const bundleCustomElements = async (
123123
chunkFileNames: outputTarget.externalRuntime || !config.hashFileNames ? '[name].js' : 'p-[hash].js',
124124
entryFileNames: '[name].js',
125125
hoistTransitiveImports: false,
126-
preferConst: true,
127126
});
128127

129128
// the output target should have been validated at this point - as a result, we expect this field

src/compiler/output-targets/dist-hydrate-script/generate-hydrate-app.ts

-2
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,6 @@ export const generateHydrateApp = async (
6262
external: ['stream'],
6363

6464
input,
65-
inlineDynamicImports: true,
6665
plugins: [
6766
{
6867
name: 'hydrateAppPlugin',
@@ -125,7 +124,6 @@ const generateHydrateFactory = async (config: d.ValidatedConfig, compilerCtx: d.
125124
strict: false,
126125
intro: HYDRATE_FACTORY_INTRO,
127126
outro: HYDRATE_FACTORY_OUTRO,
128-
preferConst: false,
129127
inlineDynamicImports: true,
130128
});
131129

src/compiler/output-targets/dist-lazy/generate-cjs.ts

-1
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,6 @@ export const generateCjs = async (
2121
format: 'cjs',
2222
entryFileNames: '[name].cjs.js',
2323
assetFileNames: '[name]-[hash][extname]',
24-
preferConst: true,
2524
sourcemap: config.sourceMap,
2625
};
2726
const results = await generateRollupOutput(rollupBuild, esmOpts, config, buildCtx.entryModules);

src/compiler/output-targets/dist-lazy/generate-esm-browser.ts

-1
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,6 @@ export const generateEsmBrowser = async (
2121
entryFileNames: '[name].esm.js',
2222
chunkFileNames: config.hashFileNames ? 'p-[hash].js' : '[name]-[hash].js',
2323
assetFileNames: config.hashFileNames ? 'p-[hash][extname]' : '[name]-[hash][extname]',
24-
preferConst: true,
2524
sourcemap: config.sourceMap,
2625
};
2726

src/compiler/output-targets/dist-lazy/generate-esm.ts

-1
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,6 @@ export const generateEsm = async (
2121
format: 'es',
2222
entryFileNames: '[name].js',
2323
assetFileNames: '[name]-[hash][extname]',
24-
preferConst: true,
2524
sourcemap: config.sourceMap,
2625
};
2726
const outputTargetType = esmOutputs[0].type;

src/compiler/output-targets/dist-lazy/generate-system.ts

-1
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,6 @@ export const generateSystem = async (
2222
entryFileNames: config.hashFileNames ? 'p-[hash].system.js' : '[name].system.js',
2323
chunkFileNames: config.hashFileNames ? 'p-[hash].system.js' : '[name]-[hash].system.js',
2424
assetFileNames: config.hashFileNames ? 'p-[hash][extname]' : '[name]-[hash][extname]',
25-
preferConst: true,
2625
sourcemap: config.sourceMap,
2726
};
2827
const results = await generateRollupOutput(rollupBuild, esmOpts, config, buildCtx.entryModules);

src/compiler/sys/resolve/resolve-module-async.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ export const resolveModuleIdAsync = (
4646
export const createCustomResolverAsync = (
4747
sys: d.CompilerSystem,
4848
inMemoryFs: InMemoryFileSystem,
49-
exts: string[],
49+
exts?: string[],
5050
): any => {
5151
return {
5252
async isFile(filePath: string, cb: (err: any, isFile: boolean) => void) {

src/declarations/stencil-public-compiler.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -1334,7 +1334,7 @@ export interface ResolveModuleIdOptions {
13341334
moduleId: string;
13351335
containingFile?: string;
13361336
exts?: string[];
1337-
packageFilter?: (pkg: any) => void;
1337+
packageFilter?: (pkg: any, pkgFile: string) => any;
13381338
}
13391339

13401340
export interface ResolveModuleIdResults {

test/browser-compile/src/components/app-root/app-root.tsx

+1-1
Original file line numberDiff line numberDiff line change
@@ -210,7 +210,7 @@ export class AppRoot {
210210
* @param entity the error that was caught
211211
* @returns `true` if the `entity` parameter is of type `RollupLogProps`, `false` otherwise
212212
*/
213-
private isRollupLogProps(entity: unknown): entity is RollupTypes.RollupLogProps {
213+
private isRollupLogProps(entity: unknown): entity is RollupTypes.RollupLog {
214214
return this.isObjectWithMessage(entity) && typeof entity.message === 'string';
215215
}
216216

test/wdio/scoped-slot-assigned-methods/cmp.tsx

+6-2
Original file line numberDiff line numberDiff line change
@@ -27,10 +27,14 @@ export class ScopedSlotAssignedMethods {
2727
render() {
2828
return (
2929
<div>
30-
<slot ref={(s: HTMLSlotElement) => (this.fbSlot = s)}>
30+
<slot
31+
ref={(slot) => {
32+
this.fbSlot = slot as HTMLSlotElement;
33+
}}
34+
>
3135
<slot name="nested-slot">Fallback content</slot>
3236
</slot>
33-
<slot name="plain-slot" ref={(s: HTMLSlotElement) => (this.plainSlot = s)} />
37+
<slot name="plain-slot" ref={(s) => (this.plainSlot = s as HTMLSlotElement)} />
3438
</div>
3539
);
3640
}

test/wdio/scoped-slot-slotchange/cmp.tsx

+5-2
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,11 @@ import { Component, h, Prop } from '@stencil/core';
77
export class ScopedSlotChange {
88
@Prop({ mutable: true }) slotEventCatch: { event: Event; assignedNodes: Node[] }[] = [];
99

10-
private handleSlotchange = (e) => {
11-
this.slotEventCatch.push({ event: e, assignedNodes: e.target.assignedNodes() });
10+
private handleSlotchange = (e: Event) => {
11+
this.slotEventCatch.push({
12+
event: e,
13+
assignedNodes: (e as Event & { target: HTMLSlotElement }).target.assignedNodes(),
14+
});
1215
};
1316

1417
render() {

0 commit comments

Comments
 (0)