From a9ba1ca90757d9dbe9a9cd1f8e2082488dd77c83 Mon Sep 17 00:00:00 2001 From: Daniel Roe Date: Tue, 8 Feb 2022 16:13:02 +0000 Subject: [PATCH] fix(bridge): support newer js targets with webpack (#3131) --- packages/bridge/package.json | 2 ++ packages/bridge/src/typescript.ts | 9 ++++++--- yarn.lock | 2 ++ 3 files changed, 10 insertions(+), 3 deletions(-) diff --git a/packages/bridge/package.json b/packages/bridge/package.json index 55cad58060..c6439451f0 100644 --- a/packages/bridge/package.json +++ b/packages/bridge/package.json @@ -18,6 +18,8 @@ "prepack": "unbuild" }, "dependencies": { + "@babel/plugin-proposal-nullish-coalescing-operator": "^7.16.7", + "@babel/plugin-proposal-optional-chaining": "^7.16.7", "@babel/plugin-transform-typescript": "^7.16.8", "@nuxt/kit": "3.0.0", "@nuxt/nitro": "3.0.0", diff --git a/packages/bridge/src/typescript.ts b/packages/bridge/src/typescript.ts index af6feaef0b..795197424f 100644 --- a/packages/bridge/src/typescript.ts +++ b/packages/bridge/src/typescript.ts @@ -10,8 +10,6 @@ export function setupTypescript () { nuxt.options.extensions.push(...extensions) nuxt.options.build.additionalExtensions.push(...extensions) - const _require = createRequire(import.meta.url) - const babelPlugin = _require.resolve('@babel/plugin-transform-typescript') nuxt.options.build.babel.plugins = nuxt.options.build.babel.plugins || [] // Error if `@nuxt/typescript-build` is added @@ -19,7 +17,12 @@ export function setupTypescript () { throw new Error('Please remove `@nuxt/typescript-build` from `buildModules` or set `bridge.typescript: false` to avoid conflict with bridge.') } - nuxt.options.build.babel.plugins.unshift(babelPlugin) + const _require = createRequire(import.meta.url) + nuxt.options.build.babel.plugins.unshift( + _require.resolve('@babel/plugin-proposal-optional-chaining'), + _require.resolve('@babel/plugin-proposal-nullish-coalescing-operator'), + _require.resolve('@babel/plugin-transform-typescript') + ) extendWebpackConfig((config) => { config.resolve.extensions!.push(...extensions.map(e => `.${e}`)) diff --git a/yarn.lock b/yarn.lock index 80739b368d..600c605709 100644 --- a/yarn.lock +++ b/yarn.lock @@ -2565,6 +2565,8 @@ __metadata: version: 0.0.0-use.local resolution: "@nuxt/bridge@workspace:packages/bridge" dependencies: + "@babel/plugin-proposal-nullish-coalescing-operator": ^7.16.7 + "@babel/plugin-proposal-optional-chaining": ^7.16.7 "@babel/plugin-transform-typescript": ^7.16.8 "@nuxt/kit": 3.0.0 "@nuxt/nitro": 3.0.0