veslx 0.0.15 → 0.0.17
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/package.json +1 -1
- package/vite.config.ts +29 -14
package/package.json
CHANGED
package/vite.config.ts
CHANGED
|
@@ -10,19 +10,36 @@ import remarkGfm from 'remark-gfm'
|
|
|
10
10
|
import remarkMdxFrontmatter from 'remark-mdx-frontmatter'
|
|
11
11
|
import { fileURLToPath } from 'url'
|
|
12
12
|
import path from 'path'
|
|
13
|
-
import { createRequire } from 'module'
|
|
14
13
|
|
|
15
14
|
const __dirname = path.dirname(fileURLToPath(import.meta.url))
|
|
16
|
-
const require = createRequire(import.meta.url)
|
|
17
|
-
|
|
18
|
-
// Resolve these packages from veslx's own node_modules to avoid CommonJS/ESM interop issues
|
|
19
|
-
const resolveFromVeslx = (pkg: string) => path.dirname(require.resolve(`${pkg}/package.json`))
|
|
20
15
|
|
|
21
16
|
export default defineConfig({
|
|
22
17
|
clearScreen: false,
|
|
23
18
|
cacheDir: path.join(__dirname, 'node_modules/.vite'),
|
|
24
19
|
publicDir: path.join(__dirname, 'public'),
|
|
25
20
|
plugins: [
|
|
21
|
+
// Plugin to fix CommonJS default exports when served via /@fs/
|
|
22
|
+
{
|
|
23
|
+
name: 'fix-cjs-default-export',
|
|
24
|
+
enforce: 'pre',
|
|
25
|
+
transform(code, id) {
|
|
26
|
+
// Only process JS files from node_modules
|
|
27
|
+
if (!id.includes('node_modules') || !id.endsWith('.js')) return null
|
|
28
|
+
|
|
29
|
+
// Skip files that are already ESM
|
|
30
|
+
if (code.includes('export default') || code.includes('export {') || code.includes('export *')) return null
|
|
31
|
+
|
|
32
|
+
// Check if it's a CommonJS module (has module.exports)
|
|
33
|
+
if (code.includes('module.exports')) {
|
|
34
|
+
// Add default export shim
|
|
35
|
+
return {
|
|
36
|
+
code: `${code}\nexport default module.exports;`,
|
|
37
|
+
map: null
|
|
38
|
+
}
|
|
39
|
+
}
|
|
40
|
+
return null
|
|
41
|
+
}
|
|
42
|
+
},
|
|
26
43
|
tailwindcss(),
|
|
27
44
|
// MDX must run before Vite's default transforms
|
|
28
45
|
{
|
|
@@ -43,15 +60,6 @@ export default defineConfig({
|
|
|
43
60
|
resolve: {
|
|
44
61
|
alias: {
|
|
45
62
|
'@': path.join(__dirname, 'src'),
|
|
46
|
-
// Force these CommonJS packages to resolve from veslx's node_modules
|
|
47
|
-
// to ensure consistent ESM interop when running from installed package
|
|
48
|
-
'acorn-jsx': resolveFromVeslx('acorn-jsx'),
|
|
49
|
-
'acorn': resolveFromVeslx('acorn'),
|
|
50
|
-
'recma-jsx': resolveFromVeslx('recma-jsx'),
|
|
51
|
-
'recma-parse': resolveFromVeslx('recma-parse'),
|
|
52
|
-
'recma-stringify': resolveFromVeslx('recma-stringify'),
|
|
53
|
-
'micromark-extension-mdxjs': resolveFromVeslx('micromark-extension-mdxjs'),
|
|
54
|
-
'estree-util-to-js': resolveFromVeslx('estree-util-to-js'),
|
|
55
63
|
},
|
|
56
64
|
},
|
|
57
65
|
server: {
|
|
@@ -71,6 +79,7 @@ export default defineConfig({
|
|
|
71
79
|
},
|
|
72
80
|
optimizeDeps: {
|
|
73
81
|
entries: [path.join(__dirname, 'src/main.tsx')],
|
|
82
|
+
// Include all CommonJS dependencies that need ESM conversion
|
|
74
83
|
include: [
|
|
75
84
|
'react',
|
|
76
85
|
'react-dom',
|
|
@@ -78,6 +87,7 @@ export default defineConfig({
|
|
|
78
87
|
'react/jsx-runtime',
|
|
79
88
|
'react/jsx-dev-runtime',
|
|
80
89
|
'@mdx-js/react',
|
|
90
|
+
'@mdx-js/mdx',
|
|
81
91
|
'react-router-dom',
|
|
82
92
|
'acorn-jsx',
|
|
83
93
|
'acorn',
|
|
@@ -89,6 +99,11 @@ export default defineConfig({
|
|
|
89
99
|
'style-to-js',
|
|
90
100
|
'style-to-object',
|
|
91
101
|
'debug',
|
|
102
|
+
'unified',
|
|
103
|
+
'extend',
|
|
104
|
+
'bail',
|
|
105
|
+
'trough',
|
|
106
|
+
'vfile',
|
|
92
107
|
],
|
|
93
108
|
},
|
|
94
109
|
})
|