This repository was archived by the owner on Dec 5, 2024. It is now read-only.
File tree Expand file tree Collapse file tree 2 files changed +14
-2
lines changed Expand file tree Collapse file tree 2 files changed +14
-2
lines changed Original file line number Diff line number Diff line change 1
1
import type { Module , NuxtOptions } from '@nuxt/types'
2
- import { relative , sep } from 'upath'
2
+ import { relative , resolve , sep } from 'upath'
3
3
4
4
import { name , version } from '../package.json'
5
5
@@ -18,10 +18,18 @@ const compositionApiModule: Module<never> = function compositionApiModule() {
18
18
19
19
addGlobalsFile . call ( this )
20
20
21
+ // Add library alias for benefit of vite
22
+
23
+ nuxtOptions . alias [ '~composition-api' ] = resolve ( __dirname , 'index.mjs' )
24
+
21
25
// Force transpilation of this library (to enable resolution of globals file)
22
26
23
27
nuxtOptions . build . transpile = nuxtOptions . build . transpile || [ ]
24
- nuxtOptions . build . transpile . push ( '@nuxtjs/composition-api' , __dirname )
28
+ nuxtOptions . build . transpile . push (
29
+ '@nuxtjs/composition-api' ,
30
+ '~composition-api' ,
31
+ __dirname
32
+ )
25
33
26
34
// Define @vue /composition-api resolution to prevent using different versions of @vue/composition-api
27
35
Original file line number Diff line number Diff line change @@ -17,6 +17,10 @@ export function compositionApiPlugin(): Plugin & { enforce: 'pre' } {
17
17
name : 'nuxt:composition-api' ,
18
18
enforce : 'pre' ,
19
19
transform ( code : string , filename : string ) {
20
+ code = code . replace (
21
+ / @ n u x t j s [ \\ / ] c o m p o s i t i o n - a p i (? ! [ \\ / ] ) / g,
22
+ '~composition-api'
23
+ )
20
24
const keyedFunctions = / ( u s e S t a t i c | s h a l l o w S s r R e f | s s r P r o m i s e | s s r R e f | r e q S s r R e f | u s e A s y n c ) /
21
25
if ( ! keyedFunctions . test ( code ) ) {
22
26
return {
You can’t perform that action at this time.
0 commit comments