@fictjs/vite-plugin 0.0.15 → 0.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.cjs +14 -4
- package/dist/index.cjs.map +1 -1
- package/dist/index.js +14 -4
- package/dist/index.js.map +1 -1
- package/package.json +2 -2
package/dist/index.cjs
CHANGED
|
@@ -40,16 +40,26 @@ function fict(options = {}) {
|
|
|
40
40
|
config = resolvedConfig;
|
|
41
41
|
isDev = config.command === "serve" || config.mode === "development";
|
|
42
42
|
},
|
|
43
|
-
config() {
|
|
43
|
+
config(userConfig) {
|
|
44
|
+
const userOptimize = userConfig.optimizeDeps;
|
|
45
|
+
const hasUserOptimize = !!userOptimize;
|
|
46
|
+
const hasDisabledOptimize = hasUserOptimize && userOptimize.disabled === true;
|
|
47
|
+
const include2 = new Set(userOptimize?.include ?? []);
|
|
48
|
+
const exclude2 = new Set(userOptimize?.exclude ?? []);
|
|
49
|
+
if (!exclude2.has("@fictjs/runtime")) {
|
|
50
|
+
include2.add("@fictjs/runtime");
|
|
51
|
+
}
|
|
44
52
|
return {
|
|
45
53
|
esbuild: {
|
|
46
54
|
// Disable esbuild JSX handling for .tsx/.jsx files
|
|
47
55
|
// Our plugin will handle the full transformation
|
|
48
56
|
include: /\.(ts|js|mts|mjs|cjs)$/
|
|
49
57
|
},
|
|
50
|
-
optimizeDeps: {
|
|
51
|
-
|
|
52
|
-
|
|
58
|
+
...hasDisabledOptimize ? { optimizeDeps: userOptimize } : {
|
|
59
|
+
optimizeDeps: hasUserOptimize ? { ...userOptimize, include: Array.from(include2) } : {
|
|
60
|
+
// Ensure @fictjs/runtime is pre-bundled
|
|
61
|
+
include: ["@fictjs/runtime"]
|
|
62
|
+
}
|
|
53
63
|
}
|
|
54
64
|
};
|
|
55
65
|
},
|
package/dist/index.cjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/index.ts"],"sourcesContent":["import { transformAsync } from '@babel/core'\nimport { createFictPlugin, type FictCompilerOptions } from '@fictjs/compiler'\nimport type { Plugin, TransformResult, ResolvedConfig } from 'vite'\n\nexport interface FictPluginOptions extends FictCompilerOptions {\n /**\n * File patterns to include for transformation.\n * @default ['**\\/*.tsx', '**\\/*.jsx']\n */\n include?: string[]\n /**\n * File patterns to exclude from transformation.\n * @default ['**\\/node_modules\\/**']\n */\n exclude?: string[]\n}\n\n/**\n * Vite plugin for Fict reactive UI library.\n *\n * Transforms $state and $effect calls into reactive signals using the Fict compiler.\n *\n * @example\n * ```ts\n * // vite.config.ts\n * import { defineConfig } from 'vite'\n * import fict from '@fictjs/vite-plugin'\n *\n * export default defineConfig({\n * plugins: [fict()],\n * })\n * ```\n */\nexport default function fict(options: FictPluginOptions = {}): Plugin {\n const {\n include = ['**/*.tsx', '**/*.jsx'],\n exclude = ['**/node_modules/**'],\n ...compilerOptions\n } = options\n\n let config: ResolvedConfig\n let isDev = false\n\n return {\n name: 'vite-plugin-fict',\n\n enforce: 'pre',\n\n configResolved(resolvedConfig) {\n config = resolvedConfig\n isDev = config.command === 'serve' || config.mode === 'development'\n },\n\n config() {\n return {\n esbuild: {\n // Disable esbuild JSX handling for .tsx/.jsx files\n // Our plugin will handle the full transformation\n include: /\\.(ts|js|mts|mjs|cjs)$/,\n },\n optimizeDeps: {\n
|
|
1
|
+
{"version":3,"sources":["../src/index.ts"],"sourcesContent":["import { transformAsync } from '@babel/core'\nimport { createFictPlugin, type FictCompilerOptions } from '@fictjs/compiler'\nimport type { Plugin, TransformResult, ResolvedConfig } from 'vite'\n\nexport interface FictPluginOptions extends FictCompilerOptions {\n /**\n * File patterns to include for transformation.\n * @default ['**\\/*.tsx', '**\\/*.jsx']\n */\n include?: string[]\n /**\n * File patterns to exclude from transformation.\n * @default ['**\\/node_modules\\/**']\n */\n exclude?: string[]\n}\n\n/**\n * Vite plugin for Fict reactive UI library.\n *\n * Transforms $state and $effect calls into reactive signals using the Fict compiler.\n *\n * @example\n * ```ts\n * // vite.config.ts\n * import { defineConfig } from 'vite'\n * import fict from '@fictjs/vite-plugin'\n *\n * export default defineConfig({\n * plugins: [fict()],\n * })\n * ```\n */\nexport default function fict(options: FictPluginOptions = {}): Plugin {\n const {\n include = ['**/*.tsx', '**/*.jsx'],\n exclude = ['**/node_modules/**'],\n ...compilerOptions\n } = options\n\n let config: ResolvedConfig\n let isDev = false\n\n return {\n name: 'vite-plugin-fict',\n\n enforce: 'pre',\n\n configResolved(resolvedConfig) {\n config = resolvedConfig\n isDev = config.command === 'serve' || config.mode === 'development'\n },\n\n config(userConfig) {\n const userOptimize = userConfig.optimizeDeps\n const hasUserOptimize = !!userOptimize\n const hasDisabledOptimize =\n hasUserOptimize && (userOptimize as { disabled?: boolean }).disabled === true\n const include = new Set(userOptimize?.include ?? [])\n const exclude = new Set(userOptimize?.exclude ?? [])\n if (!exclude.has('@fictjs/runtime')) {\n include.add('@fictjs/runtime')\n }\n return {\n esbuild: {\n // Disable esbuild JSX handling for .tsx/.jsx files\n // Our plugin will handle the full transformation\n include: /\\.(ts|js|mts|mjs|cjs)$/,\n },\n ...(hasDisabledOptimize\n ? { optimizeDeps: userOptimize }\n : {\n optimizeDeps: hasUserOptimize\n ? { ...userOptimize, include: Array.from(include) }\n : {\n // Ensure @fictjs/runtime is pre-bundled\n include: ['@fictjs/runtime'],\n },\n }),\n }\n },\n\n async transform(code: string, id: string): Promise<TransformResult | null> {\n const filename = stripQuery(id)\n\n // Skip non-matching files\n if (!shouldTransform(filename, include, exclude)) {\n return null\n }\n\n try {\n // Pass dev mode to compiler for debug instrumentation\n const fictOptions: FictCompilerOptions = {\n ...compilerOptions,\n dev: compilerOptions.dev ?? isDev,\n sourcemap: compilerOptions.sourcemap ?? true,\n }\n\n const isTypeScript = filename.endsWith('.tsx') || filename.endsWith('.ts')\n\n const result = await transformAsync(code, {\n filename,\n sourceMaps: fictOptions.sourcemap,\n sourceFileName: filename,\n presets: isTypeScript\n ? [['@babel/preset-typescript', { isTSX: true, allExtensions: true }]]\n : [],\n plugins: [\n ['@babel/plugin-syntax-jsx', {}],\n [createFictPlugin, fictOptions],\n ],\n })\n\n if (!result || !result.code) {\n return null\n }\n\n return {\n code: result.code,\n map: result.map as TransformResult['map'],\n }\n } catch (error) {\n // Better error handling\n const message =\n error instanceof Error ? error.message : 'Unknown error during Fict transformation'\n\n this.error({\n message: `[fict] Transform failed for ${id}: ${message}`,\n id,\n })\n\n return null\n }\n },\n\n handleHotUpdate({ file, server }) {\n // Force full reload for .tsx/.jsx files to ensure reactive graph is rebuilt\n if (shouldTransform(file, include, exclude)) {\n server.ws.send({\n type: 'full-reload',\n path: '*',\n })\n }\n },\n }\n}\n\n/**\n * Check if a file should be transformed based on include/exclude patterns\n */\nfunction shouldTransform(id: string, include: string[], exclude: string[]): boolean {\n // Normalize path separators\n const normalizedId = stripQuery(id).replace(/\\\\/g, '/')\n\n // Check exclude patterns first\n for (const pattern of exclude) {\n if (matchPattern(normalizedId, pattern)) {\n return false\n }\n }\n\n // Check include patterns\n for (const pattern of include) {\n if (matchPattern(normalizedId, pattern)) {\n return true\n }\n }\n\n return false\n}\n\n/**\n * Simple glob pattern matching\n * Supports: **\\/*.ext, *.ext, exact matches\n */\nfunction matchPattern(id: string, pattern: string): boolean {\n // Exact match\n if (id === pattern) return true\n\n // Simple check: if pattern ends with extension like *.tsx, just check if file ends with it\n if (pattern.startsWith('**/') || pattern.startsWith('*')) {\n const ext = pattern.replace(/^\\*\\*?\\//, '')\n if (ext.startsWith('*')) {\n // **/*.tsx -> check if ends with .tsx\n const ending = ext.replace(/^\\*/, '')\n return id.endsWith(ending)\n }\n }\n\n // Convert glob pattern to regex\n const regexPattern = pattern\n .replace(/\\./g, '\\\\.') // Escape dots\n .replace(/\\*\\*/g, '.*') // ** matches any path\n .replace(/\\*/g, '[^/]*') // * matches any non-slash\n\n const regex = new RegExp(`^${regexPattern}$`)\n return regex.test(id)\n}\n\n/**\n * Remove Vite query parameters (e.g. ?import, ?v=123) from an id\n */\nfunction stripQuery(id: string): string {\n const queryStart = id.indexOf('?')\n return queryStart === -1 ? id : id.slice(0, queryStart)\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,kBAA+B;AAC/B,sBAA2D;AAgC5C,SAAR,KAAsB,UAA6B,CAAC,GAAW;AACpE,QAAM;AAAA,IACJ,UAAU,CAAC,YAAY,UAAU;AAAA,IACjC,UAAU,CAAC,oBAAoB;AAAA,IAC/B,GAAG;AAAA,EACL,IAAI;AAEJ,MAAI;AACJ,MAAI,QAAQ;AAEZ,SAAO;AAAA,IACL,MAAM;AAAA,IAEN,SAAS;AAAA,IAET,eAAe,gBAAgB;AAC7B,eAAS;AACT,cAAQ,OAAO,YAAY,WAAW,OAAO,SAAS;AAAA,IACxD;AAAA,IAEA,OAAO,YAAY;AACjB,YAAM,eAAe,WAAW;AAChC,YAAM,kBAAkB,CAAC,CAAC;AAC1B,YAAM,sBACJ,mBAAoB,aAAwC,aAAa;AAC3E,YAAMA,WAAU,IAAI,IAAI,cAAc,WAAW,CAAC,CAAC;AACnD,YAAMC,WAAU,IAAI,IAAI,cAAc,WAAW,CAAC,CAAC;AACnD,UAAI,CAACA,SAAQ,IAAI,iBAAiB,GAAG;AACnC,QAAAD,SAAQ,IAAI,iBAAiB;AAAA,MAC/B;AACA,aAAO;AAAA,QACL,SAAS;AAAA;AAAA;AAAA,UAGP,SAAS;AAAA,QACX;AAAA,QACA,GAAI,sBACA,EAAE,cAAc,aAAa,IAC7B;AAAA,UACE,cAAc,kBACV,EAAE,GAAG,cAAc,SAAS,MAAM,KAAKA,QAAO,EAAE,IAChD;AAAA;AAAA,YAEE,SAAS,CAAC,iBAAiB;AAAA,UAC7B;AAAA,QACN;AAAA,MACN;AAAA,IACF;AAAA,IAEA,MAAM,UAAU,MAAc,IAA6C;AACzE,YAAM,WAAW,WAAW,EAAE;AAG9B,UAAI,CAAC,gBAAgB,UAAU,SAAS,OAAO,G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ACT;AAAA,EACF;AAGA,aAAW,WAAW,SAAS;AAC7B,QAAI,aAAa,cAAc,OAAO,GAAG;AACvC,aAAO;AAAA,IACT;AAAA,EACF;AAEA,SAAO;AACT;AAMA,SAAS,aAAa,IAAY,SAA0B;AAE1D,MAAI,OAAO,QAAS,QAAO;AAG3B,MAAI,QAAQ,WAAW,KAAK,KAAK,QAAQ,WAAW,GAAG,GAAG;AACxD,UAAM,MAAM,QAAQ,QAAQ,YAAY,EAAE;AAC1C,QAAI,IAAI,WAAW,GAAG,GAAG;AAEvB,YAAM,SAAS,IAAI,QAAQ,OAAO,EAAE;AACpC,aAAO,GAAG,SAAS,MAAM;AAAA,IAC3B;AAAA,EACF;AAGA,QAAM,eAAe,QAClB,QAAQ,OAAO,KAAK,EACpB,QAAQ,SAAS,IAAI,EACrB,QAAQ,OAAO,OAAO;AAEzB,QAAM,QAAQ,IAAI,OAAO,IAAI,YAAY,GAAG;AAC5C,SAAO,MAAM,KAAK,EAAE;AACtB;AAKA,SAAS,WAAW,IAAoB;AACtC,QAAM,aAAa,GAAG,QAAQ,GAAG;AACjC,SAAO,eAAe,KAAK,KAAK,GAAG,MAAM,GAAG,UAAU;AACxD;","names":["include","exclude"]}
|
package/dist/index.js
CHANGED
|
@@ -16,16 +16,26 @@ function fict(options = {}) {
|
|
|
16
16
|
config = resolvedConfig;
|
|
17
17
|
isDev = config.command === "serve" || config.mode === "development";
|
|
18
18
|
},
|
|
19
|
-
config() {
|
|
19
|
+
config(userConfig) {
|
|
20
|
+
const userOptimize = userConfig.optimizeDeps;
|
|
21
|
+
const hasUserOptimize = !!userOptimize;
|
|
22
|
+
const hasDisabledOptimize = hasUserOptimize && userOptimize.disabled === true;
|
|
23
|
+
const include2 = new Set(userOptimize?.include ?? []);
|
|
24
|
+
const exclude2 = new Set(userOptimize?.exclude ?? []);
|
|
25
|
+
if (!exclude2.has("@fictjs/runtime")) {
|
|
26
|
+
include2.add("@fictjs/runtime");
|
|
27
|
+
}
|
|
20
28
|
return {
|
|
21
29
|
esbuild: {
|
|
22
30
|
// Disable esbuild JSX handling for .tsx/.jsx files
|
|
23
31
|
// Our plugin will handle the full transformation
|
|
24
32
|
include: /\.(ts|js|mts|mjs|cjs)$/
|
|
25
33
|
},
|
|
26
|
-
optimizeDeps: {
|
|
27
|
-
|
|
28
|
-
|
|
34
|
+
...hasDisabledOptimize ? { optimizeDeps: userOptimize } : {
|
|
35
|
+
optimizeDeps: hasUserOptimize ? { ...userOptimize, include: Array.from(include2) } : {
|
|
36
|
+
// Ensure @fictjs/runtime is pre-bundled
|
|
37
|
+
include: ["@fictjs/runtime"]
|
|
38
|
+
}
|
|
29
39
|
}
|
|
30
40
|
};
|
|
31
41
|
},
|
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/index.ts"],"sourcesContent":["import { transformAsync } from '@babel/core'\nimport { createFictPlugin, type FictCompilerOptions } from '@fictjs/compiler'\nimport type { Plugin, TransformResult, ResolvedConfig } from 'vite'\n\nexport interface FictPluginOptions extends FictCompilerOptions {\n /**\n * File patterns to include for transformation.\n * @default ['**\\/*.tsx', '**\\/*.jsx']\n */\n include?: string[]\n /**\n * File patterns to exclude from transformation.\n * @default ['**\\/node_modules\\/**']\n */\n exclude?: string[]\n}\n\n/**\n * Vite plugin for Fict reactive UI library.\n *\n * Transforms $state and $effect calls into reactive signals using the Fict compiler.\n *\n * @example\n * ```ts\n * // vite.config.ts\n * import { defineConfig } from 'vite'\n * import fict from '@fictjs/vite-plugin'\n *\n * export default defineConfig({\n * plugins: [fict()],\n * })\n * ```\n */\nexport default function fict(options: FictPluginOptions = {}): Plugin {\n const {\n include = ['**/*.tsx', '**/*.jsx'],\n exclude = ['**/node_modules/**'],\n ...compilerOptions\n } = options\n\n let config: ResolvedConfig\n let isDev = false\n\n return {\n name: 'vite-plugin-fict',\n\n enforce: 'pre',\n\n configResolved(resolvedConfig) {\n config = resolvedConfig\n isDev = config.command === 'serve' || config.mode === 'development'\n },\n\n config() {\n return {\n esbuild: {\n // Disable esbuild JSX handling for .tsx/.jsx files\n // Our plugin will handle the full transformation\n include: /\\.(ts|js|mts|mjs|cjs)$/,\n },\n optimizeDeps: {\n
|
|
1
|
+
{"version":3,"sources":["../src/index.ts"],"sourcesContent":["import { transformAsync } from '@babel/core'\nimport { createFictPlugin, type FictCompilerOptions } from '@fictjs/compiler'\nimport type { Plugin, TransformResult, ResolvedConfig } from 'vite'\n\nexport interface FictPluginOptions extends FictCompilerOptions {\n /**\n * File patterns to include for transformation.\n * @default ['**\\/*.tsx', '**\\/*.jsx']\n */\n include?: string[]\n /**\n * File patterns to exclude from transformation.\n * @default ['**\\/node_modules\\/**']\n */\n exclude?: string[]\n}\n\n/**\n * Vite plugin for Fict reactive UI library.\n *\n * Transforms $state and $effect calls into reactive signals using the Fict compiler.\n *\n * @example\n * ```ts\n * // vite.config.ts\n * import { defineConfig } from 'vite'\n * import fict from '@fictjs/vite-plugin'\n *\n * export default defineConfig({\n * plugins: [fict()],\n * })\n * ```\n */\nexport default function fict(options: FictPluginOptions = {}): Plugin {\n const {\n include = ['**/*.tsx', '**/*.jsx'],\n exclude = ['**/node_modules/**'],\n ...compilerOptions\n } = options\n\n let config: ResolvedConfig\n let isDev = false\n\n return {\n name: 'vite-plugin-fict',\n\n enforce: 'pre',\n\n configResolved(resolvedConfig) {\n config = resolvedConfig\n isDev = config.command === 'serve' || config.mode === 'development'\n },\n\n config(userConfig) {\n const userOptimize = userConfig.optimizeDeps\n const hasUserOptimize = !!userOptimize\n const hasDisabledOptimize =\n hasUserOptimize && (userOptimize as { disabled?: boolean }).disabled === true\n const include = new Set(userOptimize?.include ?? [])\n const exclude = new Set(userOptimize?.exclude ?? [])\n if (!exclude.has('@fictjs/runtime')) {\n include.add('@fictjs/runtime')\n }\n return {\n esbuild: {\n // Disable esbuild JSX handling for .tsx/.jsx files\n // Our plugin will handle the full transformation\n include: /\\.(ts|js|mts|mjs|cjs)$/,\n },\n ...(hasDisabledOptimize\n ? { optimizeDeps: userOptimize }\n : {\n optimizeDeps: hasUserOptimize\n ? { ...userOptimize, include: Array.from(include) }\n : {\n // Ensure @fictjs/runtime is pre-bundled\n include: ['@fictjs/runtime'],\n },\n }),\n }\n },\n\n async transform(code: string, id: string): Promise<TransformResult | null> {\n const filename = stripQuery(id)\n\n // Skip non-matching files\n if (!shouldTransform(filename, include, exclude)) {\n return null\n }\n\n try {\n // Pass dev mode to compiler for debug instrumentation\n const fictOptions: FictCompilerOptions = {\n ...compilerOptions,\n dev: compilerOptions.dev ?? isDev,\n sourcemap: compilerOptions.sourcemap ?? true,\n }\n\n const isTypeScript = filename.endsWith('.tsx') || filename.endsWith('.ts')\n\n const result = await transformAsync(code, {\n filename,\n sourceMaps: fictOptions.sourcemap,\n sourceFileName: filename,\n presets: isTypeScript\n ? [['@babel/preset-typescript', { isTSX: true, allExtensions: true }]]\n : [],\n plugins: [\n ['@babel/plugin-syntax-jsx', {}],\n [createFictPlugin, fictOptions],\n ],\n })\n\n if (!result || !result.code) {\n return null\n }\n\n return {\n code: result.code,\n map: result.map as TransformResult['map'],\n }\n } catch (error) {\n // Better error handling\n const message =\n error instanceof Error ? error.message : 'Unknown error during Fict transformation'\n\n this.error({\n message: `[fict] Transform failed for ${id}: ${message}`,\n id,\n })\n\n return null\n }\n },\n\n handleHotUpdate({ file, server }) {\n // Force full reload for .tsx/.jsx files to ensure reactive graph is rebuilt\n if (shouldTransform(file, include, exclude)) {\n server.ws.send({\n type: 'full-reload',\n path: '*',\n })\n }\n },\n }\n}\n\n/**\n * Check if a file should be transformed based on include/exclude patterns\n */\nfunction shouldTransform(id: string, include: string[], exclude: string[]): boolean {\n // Normalize path separators\n const normalizedId = stripQuery(id).replace(/\\\\/g, '/')\n\n // Check exclude patterns first\n for (const pattern of exclude) {\n if (matchPattern(normalizedId, pattern)) {\n return false\n }\n }\n\n // Check include patterns\n for (const pattern of include) {\n if (matchPattern(normalizedId, pattern)) {\n return true\n }\n }\n\n return false\n}\n\n/**\n * Simple glob pattern matching\n * Supports: **\\/*.ext, *.ext, exact matches\n */\nfunction matchPattern(id: string, pattern: string): boolean {\n // Exact match\n if (id === pattern) return true\n\n // Simple check: if pattern ends with extension like *.tsx, just check if file ends with it\n if (pattern.startsWith('**/') || pattern.startsWith('*')) {\n const ext = pattern.replace(/^\\*\\*?\\//, '')\n if (ext.startsWith('*')) {\n // **/*.tsx -> check if ends with .tsx\n const ending = ext.replace(/^\\*/, '')\n return id.endsWith(ending)\n }\n }\n\n // Convert glob pattern to regex\n const regexPattern = pattern\n .replace(/\\./g, '\\\\.') // Escape dots\n .replace(/\\*\\*/g, '.*') // ** matches any path\n .replace(/\\*/g, '[^/]*') // * matches any non-slash\n\n const regex = new RegExp(`^${regexPattern}$`)\n return regex.test(id)\n}\n\n/**\n * Remove Vite query parameters (e.g. ?import, ?v=123) from an id\n */\nfunction stripQuery(id: string): string {\n const queryStart = id.indexOf('?')\n return queryStart === -1 ? id : id.slice(0, queryStart)\n}\n"],"mappings":";AAAA,SAAS,sBAAsB;AAC/B,SAAS,wBAAkD;AAgC5C,SAAR,KAAsB,UAA6B,CAAC,GAAW;AACpE,QAAM;AAAA,IACJ,UAAU,CAAC,YAAY,UAAU;AAAA,IACjC,UAAU,CAAC,oBAAoB;AAAA,IAC/B,GAAG;AAAA,EACL,IAAI;AAEJ,MAAI;AACJ,MAAI,QAAQ;AAEZ,SAAO;AAAA,IACL,MAAM;AAAA,IAEN,SAAS;AAAA,IAET,eAAe,gBAAgB;AAC7B,eAAS;AACT,cAAQ,OAAO,YAAY,WAAW,OAAO,SAAS;AAAA,IACxD;AAAA,IAEA,OAAO,YAAY;AACjB,YAAM,eAAe,WAAW;AAChC,YAAM,kBAAkB,CAAC,CAAC;AAC1B,YAAM,sBACJ,mBAAoB,aAAwC,aAAa;AAC3E,YAAMA,WAAU,IAAI,IAAI,cAAc,WAAW,CAAC,CAAC;AACnD,YAAMC,WAAU,IAAI,IAAI,cAAc,WAAW,C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D;","names":["include","exclude"]}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@fictjs/vite-plugin",
|
|
3
|
-
"version": "0.0
|
|
3
|
+
"version": "0.1.0",
|
|
4
4
|
"description": "Vite plugin for Fict",
|
|
5
5
|
"publishConfig": {
|
|
6
6
|
"access": "public",
|
|
@@ -33,7 +33,7 @@
|
|
|
33
33
|
"@babel/plugin-syntax-jsx": "^7.27.1",
|
|
34
34
|
"@babel/plugin-transform-react-jsx": "^7.25.9",
|
|
35
35
|
"@babel/preset-typescript": "^7.26.0",
|
|
36
|
-
"@fictjs/compiler": "0.0
|
|
36
|
+
"@fictjs/compiler": "0.1.0"
|
|
37
37
|
},
|
|
38
38
|
"devDependencies": {
|
|
39
39
|
"@types/babel__core": "^7.20.5",
|