Skip to content

Commit

Permalink
feat: add compositionAPI flag in jsx babel configuration (#304)
Browse files Browse the repository at this point in the history
  • Loading branch information
mathieutu authored Jan 25, 2021
1 parent acdf18d commit fec4218
Showing 1 changed file with 22 additions and 0 deletions.
22 changes: 22 additions & 0 deletions src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,7 @@ const compositionApiModule: Module<any> = function compositionApiModule() {

this.options.build = this.options.build || {}
this.options.build.babel = this.options.build.babel || {}

this.options.build.babel.plugins = this.options.build.babel.plugins || []
if (this.options.build.babel.plugins instanceof Function) {
console.warn(
Expand All @@ -93,6 +94,27 @@ const compositionApiModule: Module<any> = function compositionApiModule() {
this.options.build.transpile = this.options.build.transpile || []
this.options.build.transpile.push(/@nuxtjs[\\/]composition-api/)

const actualPresets = this.options.build.babel.presets

this.options.build.babel.presets = (
env,
[defaultPreset, defaultOptions]: [string, Record<string, any>]
) => {
const newOptions = {
...defaultOptions,
jsx: {
...(typeof defaultOptions.jsx === 'object' ? defaultOptions.jsx : {}),
compositionAPI: true,
},
}

if (typeof actualPresets === 'function') {
return actualPresets(env, [defaultPreset, newOptions])
}

return [[defaultPreset, newOptions]]
}

this.extendBuild(config => {
config.resolve = config.resolve || {}
config.resolve.alias = config.resolve.alias || {}
Expand Down

1 comment on commit fec4218

@vercel
Copy link

@vercel vercel bot commented on fec4218 Jan 25, 2021

Choose a reason for hiding this comment

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

Please sign in to comment.