From 01ede84b7264b1b2e4ea691ca1fe5ee40c28b61b Mon Sep 17 00:00:00 2001 From: Valentin Palkovic Date: Tue, 23 Jan 2024 13:58:24 +0100 Subject: [PATCH 1/2] Apply aliasing of node API's only for browser builds --- scripts/prepare/addon-bundle.ts | 46 ++++++++++++--------------------- 1 file changed, 16 insertions(+), 30 deletions(-) diff --git a/scripts/prepare/addon-bundle.ts b/scripts/prepare/addon-bundle.ts index b274f00e3c2e..6638039464a5 100755 --- a/scripts/prepare/addon-bundle.ts +++ b/scripts/prepare/addon-bundle.ts @@ -71,6 +71,11 @@ 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'), @@ -78,6 +83,14 @@ const run = async ({ cwd, flags }: { cwd: string; flags: string[] }) => { 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 = [ @@ -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, @@ -138,21 +142,12 @@ 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 */ - }, }) ); } @@ -160,21 +155,12 @@ const run = async ({ cwd, flags }: { cwd: string; flags: string[] }) => { 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 */ - }, }) ); } From 8020d31052777573246a02f84f58cbe7a7d197df Mon Sep 17 00:00:00 2001 From: Valentin Palkovic Date: Tue, 23 Jan 2024 13:58:37 +0100 Subject: [PATCH 2/2] Add preset.js to interactions package.json --- code/addons/interactions/package.json | 1 + 1 file changed, 1 insertion(+) diff --git a/code/addons/interactions/package.json b/code/addons/interactions/package.json index 46e00da78797..992ba4115f51 100644 --- a/code/addons/interactions/package.json +++ b/code/addons/interactions/package.json @@ -30,6 +30,7 @@ }, "./manager": "./dist/manager.js", "./preview": "./dist/preview.js", + "./preset": "./dist/preset.js", "./register.js": "./dist/manager.js", "./package.json": "./package.json" },