veslx 0.0.15 → 0.0.16
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 +32 -13
package/package.json
CHANGED
package/vite.config.ts
CHANGED
|
@@ -10,19 +10,40 @@ 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
15
|
|
|
18
|
-
//
|
|
19
|
-
const
|
|
16
|
+
// CommonJS packages that need default export shimming when served via /@fs/
|
|
17
|
+
const cjsPackages = ['extend', 'acorn-jsx', 'bail', 'trough', 'is-plain-obj']
|
|
20
18
|
|
|
21
19
|
export default defineConfig({
|
|
22
20
|
clearScreen: false,
|
|
23
21
|
cacheDir: path.join(__dirname, 'node_modules/.vite'),
|
|
24
22
|
publicDir: path.join(__dirname, 'public'),
|
|
25
23
|
plugins: [
|
|
24
|
+
// Plugin to fix CommonJS default exports when served via /@fs/
|
|
25
|
+
{
|
|
26
|
+
name: 'fix-cjs-default-export',
|
|
27
|
+
enforce: 'pre',
|
|
28
|
+
transform(code, id) {
|
|
29
|
+
// Only process CommonJS files from node_modules served via /@fs/
|
|
30
|
+
if (!id.includes('node_modules') || !id.endsWith('.js')) return null
|
|
31
|
+
|
|
32
|
+
// Check if it's a problematic CJS package
|
|
33
|
+
const isCjsPackage = cjsPackages.some(pkg => id.includes(`/${pkg}/`))
|
|
34
|
+
if (!isCjsPackage) return null
|
|
35
|
+
|
|
36
|
+
// Check if it's a CommonJS module (has module.exports but no export default)
|
|
37
|
+
if (code.includes('module.exports') && !code.includes('export default') && !code.includes('export {')) {
|
|
38
|
+
// Wrap the CommonJS module to provide a default export
|
|
39
|
+
return {
|
|
40
|
+
code: `${code}\nexport default module.exports;`,
|
|
41
|
+
map: null
|
|
42
|
+
}
|
|
43
|
+
}
|
|
44
|
+
return null
|
|
45
|
+
}
|
|
46
|
+
},
|
|
26
47
|
tailwindcss(),
|
|
27
48
|
// MDX must run before Vite's default transforms
|
|
28
49
|
{
|
|
@@ -43,15 +64,6 @@ export default defineConfig({
|
|
|
43
64
|
resolve: {
|
|
44
65
|
alias: {
|
|
45
66
|
'@': 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
67
|
},
|
|
56
68
|
},
|
|
57
69
|
server: {
|
|
@@ -71,6 +83,7 @@ export default defineConfig({
|
|
|
71
83
|
},
|
|
72
84
|
optimizeDeps: {
|
|
73
85
|
entries: [path.join(__dirname, 'src/main.tsx')],
|
|
86
|
+
// Include all CommonJS dependencies that need ESM conversion
|
|
74
87
|
include: [
|
|
75
88
|
'react',
|
|
76
89
|
'react-dom',
|
|
@@ -78,6 +91,7 @@ export default defineConfig({
|
|
|
78
91
|
'react/jsx-runtime',
|
|
79
92
|
'react/jsx-dev-runtime',
|
|
80
93
|
'@mdx-js/react',
|
|
94
|
+
'@mdx-js/mdx',
|
|
81
95
|
'react-router-dom',
|
|
82
96
|
'acorn-jsx',
|
|
83
97
|
'acorn',
|
|
@@ -89,6 +103,11 @@ export default defineConfig({
|
|
|
89
103
|
'style-to-js',
|
|
90
104
|
'style-to-object',
|
|
91
105
|
'debug',
|
|
106
|
+
'unified',
|
|
107
|
+
'extend',
|
|
108
|
+
'bail',
|
|
109
|
+
'trough',
|
|
110
|
+
'vfile',
|
|
92
111
|
],
|
|
93
112
|
},
|
|
94
113
|
})
|