veslx 0.0.16 → 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 +6 -10
package/package.json
CHANGED
package/vite.config.ts
CHANGED
|
@@ -13,9 +13,6 @@ import path from 'path'
|
|
|
13
13
|
|
|
14
14
|
const __dirname = path.dirname(fileURLToPath(import.meta.url))
|
|
15
15
|
|
|
16
|
-
// CommonJS packages that need default export shimming when served via /@fs/
|
|
17
|
-
const cjsPackages = ['extend', 'acorn-jsx', 'bail', 'trough', 'is-plain-obj']
|
|
18
|
-
|
|
19
16
|
export default defineConfig({
|
|
20
17
|
clearScreen: false,
|
|
21
18
|
cacheDir: path.join(__dirname, 'node_modules/.vite'),
|
|
@@ -26,16 +23,15 @@ export default defineConfig({
|
|
|
26
23
|
name: 'fix-cjs-default-export',
|
|
27
24
|
enforce: 'pre',
|
|
28
25
|
transform(code, id) {
|
|
29
|
-
// Only process
|
|
26
|
+
// Only process JS files from node_modules
|
|
30
27
|
if (!id.includes('node_modules') || !id.endsWith('.js')) return null
|
|
31
28
|
|
|
32
|
-
//
|
|
33
|
-
|
|
34
|
-
if (!isCjsPackage) return null
|
|
29
|
+
// Skip files that are already ESM
|
|
30
|
+
if (code.includes('export default') || code.includes('export {') || code.includes('export *')) return null
|
|
35
31
|
|
|
36
|
-
// Check if it's a CommonJS module (has module.exports
|
|
37
|
-
if (code.includes('module.exports')
|
|
38
|
-
//
|
|
32
|
+
// Check if it's a CommonJS module (has module.exports)
|
|
33
|
+
if (code.includes('module.exports')) {
|
|
34
|
+
// Add default export shim
|
|
39
35
|
return {
|
|
40
36
|
code: `${code}\nexport default module.exports;`,
|
|
41
37
|
map: null
|