File tree Expand file tree Collapse file tree 5 files changed +424
-213
lines changed
Expand file tree Collapse file tree 5 files changed +424
-213
lines changed Original file line number Diff line number Diff line change 11{
22 "name" : " nuxt-xstate" ,
3- "version" : " 0.3.1" ,
3+ "version" : " 0.3.1-alpha.1 " ,
44 "license" : " MIT" ,
55 "type" : " module" ,
66 "repository" : " Lexpeartha/nuxt-xstate" ,
4343 "test:coverage" : " vitest run --coverage"
4444 },
4545 "dependencies" : {
46- "@nuxt/kit" : " ^3.0.0-rc.9 " ,
46+ "@nuxt/kit" : " ^3.0.0-rc.10 " ,
4747 "@xstate/fsm" : " ^2.0.0" ,
4848 "@xstate/vue" : " ^2.0.0" ,
4949 "globby" : " ^13.1.2" ,
5353 },
5454 "devDependencies" : {
5555 "@nuxt/module-builder" : " latest" ,
56- "@nuxt/schema" : " ^3.0.0-rc.9 " ,
57- "@nuxt/test-utils-edge" : " ^3.0.0-rc.9 " ,
58- "@nuxt/vite-builder" : " ^3.0.0-rc.9 " ,
59- "@nuxt/webpack-builder" : " ^3.0.0-rc.9 " ,
56+ "@nuxt/schema" : " ^3.0.0-rc.10 " ,
57+ "@nuxt/test-utils-edge" : " ^3.0.0-rc.10 " ,
58+ "@nuxt/vite-builder" : " ^3.0.0-rc.10 " ,
59+ "@nuxt/webpack-builder" : " ^3.0.0-rc.10 " ,
6060 "@nuxtjs/eslint-config-typescript" : " 11.0.0" ,
6161 "eslint" : " latest" ,
62- "nuxt" : " ^3.0.0-rc.9 " ,
62+ "nuxt" : " ^3.0.0-rc.10 " ,
6363 "playwright" : " ^1.25.2" ,
6464 "typescript" : " ^4.8.3" ,
65- "vitepress" : " v1.0.0-alpha.13 " ,
65+ "vitepress" : " v1.0.0-alpha.14 " ,
6666 "vitest" : " ^0.22.0" ,
6767 "vue" : " ^3.2.39" ,
6868 "vue-demi" : " ^0.13.11" ,
Original file line number Diff line number Diff line change 1- import { defineNuxtConfig } from 'nuxt'
1+ import { defineNuxtConfig } from 'nuxt/config '
22import XStateModule from '../src/module'
33
44export default defineNuxtConfig ( {
Original file line number Diff line number Diff line change 1- import { useNuxt } from '@nuxt/kit'
1+ import { addImportsSources } from '@nuxt/kit'
22import { defineUnimportPreset } from 'unimport'
33
44export const setupAutoImports = ( isMinimal : boolean ) => {
5- const nuxt = useNuxt ( )
6-
7- nuxt . hook ( 'imports:sources' , ( presets ) => {
8- // If minimal options is enabled import required
9- // things from @xstate /vue/lib/fsm or @xstate /fsm
10- if ( isMinimal ) {
11- presets . push (
12- defineUnimportPreset ( {
13- from : '@xstate/fsm' ,
14- imports : [ ...xStateImports ]
15- } ) ,
16- defineUnimportPreset ( {
17- from : '@xstate/vue' ,
18- imports : xStateComposables . filter ( composable => composable !== 'useMachine' )
19- } ) ,
20- defineUnimportPreset ( {
21- from : '@xstate/vue/lib/fsm.js' ,
22- imports : [ 'useMachine' ]
23- } )
24- )
25-
26- return
27- }
28-
29- // Otherwise import everything regularly
30- presets . push (
5+ // If minimal options is enabled import required
6+ // things from @xstate /vue/lib/fsm or @xstate /fsm
7+ if ( isMinimal ) {
8+ addImportsSources ( [
319 defineUnimportPreset ( {
32- from : 'xstate' ,
10+ from : '@ xstate/fsm ' ,
3311 imports : [ ...xStateImports ]
3412 } ) ,
3513 defineUnimportPreset ( {
3614 from : '@xstate/vue' ,
37- imports : [ ...xStateComposables ]
15+ imports : xStateComposables . filter ( composable => composable !== 'useMachine' )
16+ } ) ,
17+ defineUnimportPreset ( {
18+ from : '@xstate/vue/lib/fsm.js' ,
19+ imports : [ 'useMachine' ]
3820 } )
39- )
40- } )
21+ ] )
22+
23+ return
24+ }
25+
26+ // Otherwise import everything regularly
27+ addImportsSources ( [
28+ defineUnimportPreset ( {
29+ from : 'xstate' ,
30+ imports : [ ...xStateImports ]
31+ } ) ,
32+ defineUnimportPreset ( {
33+ from : '@xstate/vue' ,
34+ imports : [ ...xStateComposables ]
35+ } )
36+ ] )
4137}
4238
4339const xStateImports = [
Original file line number Diff line number Diff line change @@ -3,16 +3,15 @@ import { useNuxt } from '@nuxt/kit'
33export const setupTranspilation = ( ) => {
44 const nuxt = useNuxt ( )
55
6- // const builder: any = nuxt.options.builder
7-
8- // Currently Webpack version breaks, follow this issue for more info:
9- // https://github.com/nuxt/framework/issues/4084
10- const libraries = [ 'xstate' , '@xstate/vue' , '@xstate/fsm' ]
11-
12- nuxt . options . vite . optimizeDeps = nuxt . options . vite . optimizeDeps || { }
13- nuxt . options . vite . optimizeDeps . include = nuxt . options . vite . optimizeDeps . include || [ ]
14- nuxt . options . vite . optimizeDeps . include . push ( ...libraries )
15-
166 nuxt . options . build . transpile = nuxt . options . build . transpile || [ ]
17- nuxt . options . build . transpile . push ( ...libraries )
7+
8+ // For some reason, xstate libraries really dislike being transpiled
9+ // by Vite, so they are only transpiled when webpack is used
10+ if ( nuxt . options . builder === '@nuxt/webpack-builder' ) {
11+ nuxt . options . build . transpile . push (
12+ 'xstate' ,
13+ '@xstate/vue' ,
14+ '@xstate/fsm'
15+ )
16+ }
1817}
You can’t perform that action at this time.
0 commit comments