Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Parsing issue with jsx files as a dependency entry point #2107

Closed
3 tasks done
amoutonbrady opened this issue Feb 19, 2021 · 0 comments
Closed
3 tasks done

Parsing issue with jsx files as a dependency entry point #2107

amoutonbrady opened this issue Feb 19, 2021 · 0 comments

Comments

@amoutonbrady
Copy link
Contributor

amoutonbrady commented Feb 19, 2021

⚠️ IMPORTANT ⚠️ Please check the following list before proceeding. If you ignore this issue template, your issue will be directly closed.

  • Read the docs.
  • Use Vite >=2.0. (1.x is no longer supported)
  • If the issue is related to 1.x -> 2.0 upgrade, read the Migration Guide first.

Describe the bug

Solid uses jsx files as entry point to be able to compile the source to different target (ssr or client). We recommend users to make the source available under a solid export mapping like so:

"exports": {
    ".": {
      "solid": "./dist/index.jsx",
      "default": "./dist/index.js"
    }
},

Through the Vite plugin for Solid, we resolve that export mapping.

It appears that on some dependencies Vite fails to parse it. I pulled the latest master locally and added some logs. I traced it back to this line: https://github.com/vitejs/vite/blob/main/packages/vite/src/node/optimizer/index.ts#L206.

Here's an example of the content causing the parsing issue: https://gist.github.com/amoutonbrady/e0ca61c8907d44b18e3631a3490a9ca8.

Here's the package.json of the package that causes the parsing issue: https://github.com/ryansolid/solid/blob/master/packages/solid-meta/package.json.

Reproduction

Here is a link to a small reproduction project: https://github.com/amoutonbrady/vite-parsing-reproduction.

Note that we are using Solid plugin but since the error happens in the pre-optimization part, this is not relevant as plugins hasn't been loaded yet.

System Info

  • vite version: 2.0.1
  • Operating System: Linux
  • Node version: 15.9.0
  • Package manager (npm/yarn/pnpm) and version: npm 7.5.4

Logs (Optional if provided reproduction)

  1. Run vite or vite build with the --debug flag.
  2. Provide the error log here.
vite-plugin-solid/playground on  master [!] via ⬢ v14.15.5 
❯ pnpx vite --debug
  vite:config bundled config file loaded in 85ms +0ms
  vite:config using resolved config: {
  vite:config   plugins: [
  vite:config     'vite:pre-alias',
  vite:config     'alias',
  vite:config     'vite:dynamic-import-polyfill',
  vite:config     'vite:resolve',
  vite:config     'vite:html',
  vite:config     'vite:css',
  vite:config     'vite:esbuild',
  vite:config     'vite:json',
  vite:config     'vite:wasm',
  vite:config     'vite:worker',
  vite:config     'vite:asset',
  vite:config     'solid',
  vite:config     'vite:define',
  vite:config     'vite:css-post',
  vite:config     'vite:client-inject',
  vite:config     'vite:import-analysis'
  vite:config   ],
  vite:config   server: {},
  vite:config   esbuild: { include: /\.ts$/ },
  vite:config   resolve: {
  vite:config     dedupe: [ 'solid-js', 'solid-js/web' ],
  vite:config     conditions: [ 'solid' ],
  vite:config     alias: [ [Object], [Object] ]
  vite:config   },
  vite:config   optimizeDeps: { include: [ 'solid-js/dev', 'solid-js/web' ] },
  vite:config   configFile: '/home/alexandre/Lab/vite-plugin-solid/playground/vite.config.ts',
  vite:config   inlineConfig: {
  vite:config     root: undefined,
  vite:config     base: undefined,
  vite:config     mode: undefined,
  vite:config     configFile: undefined,
  vite:config     logLevel: undefined,
  vite:config     clearScreen: undefined,
  vite:config     server: {}
  vite:config   },
  vite:config   root: '/home/alexandre/Lab/vite-plugin-solid/playground',
  vite:config   base: '/',
  vite:config   publicDir: '/home/alexandre/Lab/vite-plugin-solid/playground/public',
  vite:config   command: 'serve',
  vite:config   mode: 'development',
  vite:config   isProduction: false,
  vite:config   optimizeCacheDir: '/home/alexandre/Lab/vite-plugin-solid/playground/node_modules/.vite',
  vite:config   build: {
  vite:config     target: [ 'es2019', 'edge16', 'firefox60', 'chrome61', 'safari11' ],
  vite:config     polyfillDynamicImport: true,
  vite:config     outDir: 'dist',
  vite:config     assetsDir: 'assets',
  vite:config     assetsInlineLimit: 4096,
  vite:config     cssCodeSplit: true,
  vite:config     sourcemap: false,
  vite:config     rollupOptions: {},
  vite:config     commonjsOptions: { include: [Array], extensions: [Array] },
  vite:config     minify: 'terser',
  vite:config     terserOptions: {},
  vite:config     cleanCssOptions: {},
  vite:config     write: true,
  vite:config     emptyOutDir: null,
  vite:config     manifest: false,
  vite:config     lib: false,
  vite:config     ssr: false,
  vite:config     ssrManifest: false,
  vite:config     brotliSize: true,
  vite:config     chunkSizeWarningLimit: 500
  vite:config   },
  vite:config   env: { BASE_URL: '/', MODE: 'development', DEV: true, PROD: false },
  vite:config   assetsInclude: [Function: assetsInclude],
  vite:config   logger: {
  vite:config     hasWarned: false,
  vite:config     info: [Function: info],
  vite:config     warn: [Function: warn],
  vite:config     error: [Function: error],
  vite:config     clearScreen: [Function: clearScreen]
  vite:config   },
  vite:config   createResolver: [Function: createResolver]
  vite:config } +2ms
  vite:deps Crawling dependencies using entries:
  vite:deps   /home/alexandre/Lab/vite-plugin-solid/playground/index.html +0ms
  vite:resolve 0ms   ./index.tsx -> /home/alexandre/Lab/vite-plugin-solid/playground/index.tsx +0ms
  vite:resolve 2ms   solid-js/dev -> /home/alexandre/Lab/vite-plugin-solid/playground/node_modules/.pnpm/[email protected]/node_modules/solid-js/dev/dist/dev.js +4ms
  vite:resolve 2ms   solid-js -> /home/alexandre/Lab/vite-plugin-solid/playground/node_modules/.pnpm/[email protected]/node_modules/solid-js/dev/dist/dev.js +0ms
  vite:resolve 0ms   solid-meta -> /home/alexandre/Lab/vite-plugin-solid/playground/node_modules/.pnpm/[email protected][email protected]/node_modules/solid-meta/dist/index.jsx +1ms
  vite:resolve 1ms   solid-app-router -> /home/alexandre/Lab/vite-plugin-solid/playground/node_modules/.pnpm/[email protected][email protected]/node_modules/solid-app-router/dist/index.jsx +1ms
  vite:resolve 1ms   solid-utils -> /home/alexandre/Lab/vite-plugin-solid/playground/node_modules/.pnpm/[email protected]/node_modules/solid-utils/dist/source/index.jsx +2ms
  vite:resolve 0ms   ./pages -> /home/alexandre/Lab/vite-plugin-solid/playground/pages/index.tsx +0ms
  vite:resolve 0ms   ./pages/about -> /home/alexandre/Lab/vite-plugin-solid/playground/pages/about.tsx +1ms
  vite:deps Scan completed in 39ms: {
  'solid-js': '/home/alexandre/Lab/vite-plugin-solid/playground/node_modules/.pnpm/[email protected]/node_modules/solid-js/dev/dist/dev.js',
  'solid-meta': '/home/alexandre/Lab/vite-plugin-solid/playground/node_modules/.pnpm/[email protected][email protected]/node_modules/solid-meta/dist/index.jsx',
  'solid-app-router': '/home/alexandre/Lab/vite-plugin-solid/playground/node_modules/.pnpm/[email protected][email protected]/node_modules/solid-app-router/dist/index.jsx',
  'solid-utils': '/home/alexandre/Lab/vite-plugin-solid/playground/node_modules/.pnpm/[email protected]/node_modules/solid-utils/dist/source/index.jsx'
} +35ms
  vite:resolve 0ms   solid-js/dev -> /home/alexandre/Lab/vite-plugin-solid/playground/node_modules/.pnpm/[email protected]/node_modules/solid-js/dev/dist/dev.js +0ms
  vite:resolve 0ms   solid-js/web -> /home/alexandre/Lab/vite-plugin-solid/playground/node_modules/.pnpm/[email protected]/node_modules/solid-js/web/dist/web.js +0ms
Pre-bundling dependencies:
  solid-js
  solid-meta
  solid-app-router
  solid-utils
  solid-js/dev
  (...and 1 more)
(this will be run only when your dependencies or config have changed)
error when starting dev server:
Error: Parse error @:61:90
    at Object.parse (/home/alexandre/Temp/vite/node_modules/es-module-lexer/dist/lexer.cjs:1:402)
    at Object.optimizeDeps (/home/alexandre/Temp/vite/packages/vite/src/node/optimizer/index.ts:207:25)
    at processTicksAndRejections (node:internal/process/task_queues:94:5)
    at runOptimize (/home/alexandre/Temp/vite/packages/vite/src/node/server/index.ts:475:40)
    at Server.httpServer.listen (/home/alexandre/Temp/vite/packages/vite/src/node/server/index.ts:489:9)
@github-actions github-actions bot locked and limited conversation to collaborators Jul 16, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

1 participant