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