Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We鈥檒l occasionally send you account related emails.

Already on GitHub? Sign in to your account

Addons: Remove Node.js internal aliasing for Node builds #25712

Merged
merged 2 commits into from
Jan 23, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions code/addons/interactions/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@
},
"./manager": "./dist/manager.js",
"./preview": "./dist/preview.js",
"./preset": "./dist/preset.js",
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could you check if this is missing in more addons? If so, correct those in this PR as well? 馃檹

"./register.js": "./dist/manager.js",
"./package.json": "./package.json"
},
Expand Down
46 changes: 16 additions & 30 deletions scripts/prepare/addon-bundle.ts
Original file line number Diff line number Diff line change
Expand Up @@ -71,13 +71,26 @@ const run = async ({ cwd, flags }: { cwd: string; flags: string[] }) => {
shims: false,
watch,
clean: false,
};

const browserOptions: Options = {
target: ['chrome100', 'safari15', 'firefox91'],
platform: 'browser',
esbuildPlugins: [
aliasPlugin({
process: require.resolve('../node_modules/process/browser.js'),
util: require.resolve('../node_modules/util/util.js'),
assert: require.resolve('browser-assert'),
}),
],
format: ['esm'],
esbuildOptions: (options) => {
/* eslint-disable no-param-reassign */
options.conditions = ['module'];
options.platform = 'browser';
Object.assign(options, getESBuildOptions(optimized));
/* eslint-enable no-param-reassign */
},
};

const commonExternals = [
Expand All @@ -98,18 +111,9 @@ const run = async ({ cwd, flags }: { cwd: string; flags: string[] }) => {
build({
...commonOptions,
...(optimized ? dtsConfig : {}),
...browserOptions,
entry: exportEntries,
format: ['esm'],
target: ['chrome100', 'safari15', 'firefox91'],
platform: 'browser',
external: [...commonExternals, ...globalManagerPackages, ...globalPreviewPackages],
esbuildOptions: (options) => {
/* eslint-disable no-param-reassign */
options.conditions = ['module'];
options.platform = 'browser';
Object.assign(options, getESBuildOptions(optimized));
/* eslint-enable no-param-reassign */
},
}),
build({
...commonOptions,
Expand Down Expand Up @@ -138,43 +142,25 @@ const run = async ({ cwd, flags }: { cwd: string; flags: string[] }) => {
tasks.push(
build({
...commonOptions,
...browserOptions,
entry: managerEntries.map((e: string) => slash(join(cwd, e))),
outExtension: () => ({
js: '.js',
}),
format: ['esm'],
target: ['chrome100', 'safari15', 'firefox91'],
platform: 'browser',
external: [...commonExternals, ...globalManagerPackages],
esbuildOptions: (options) => {
/* eslint-disable no-param-reassign */
options.conditions = ['module'];
options.platform = 'browser';
Object.assign(options, getESBuildOptions(optimized));
/* eslint-enable no-param-reassign */
},
})
);
}
if (previewEntries.length > 0) {
tasks.push(
build({
...commonOptions,
...browserOptions,
entry: previewEntries.map((e: string) => slash(join(cwd, e))),
outExtension: () => ({
js: '.js',
}),
format: ['esm'],
target: ['chrome100', 'safari15', 'firefox91'],
platform: 'browser',
external: [...commonExternals, ...globalPreviewPackages],
esbuildOptions: (c) => {
/* eslint-disable no-param-reassign */
c.conditions = ['module'];
c.platform = 'browser';
Object.assign(c, getESBuildOptions(optimized));
/* eslint-enable no-param-reassign */
},
})
);
}
Expand Down