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.
Files changed (2) hide show
  1. package/package.json +1 -1
  2. package/vite.config.ts +6 -10
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "veslx",
3
- "version": "0.0.16",
3
+ "version": "0.0.17",
4
4
  "type": "module",
5
5
  "bin": {
6
6
  "veslx": "bin/veslx.ts"
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 CommonJS files from node_modules served via /@fs/
26
+ // Only process JS files from node_modules
30
27
  if (!id.includes('node_modules') || !id.endsWith('.js')) return null
31
28
 
32
- // Check if it's a problematic CJS package
33
- const isCjsPackage = cjsPackages.some(pkg => id.includes(`/${pkg}/`))
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 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
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