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

Missing "." export in "package-name" package #1505

Closed
3 tasks done
sibbng opened this issue Jan 12, 2021 · 2 comments
Closed
3 tasks done

Missing "." export in "package-name" package #1505

sibbng opened this issue Jan 12, 2021 · 2 comments

Comments

@sibbng
Copy link
Contributor

sibbng commented Jan 12, 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

Hi, I'm currently working on https://github.com/antfu/reactivue/tree/b48200b9b0c5c2e02cf7855e1568f11c808de43c tree.
Using build of this tree in react-ts template. Running vite dev is fine but vite build prompts an error on console. This issue occurs on 2.0.0-beta.23. I tested it on 2.0.0-beta.21, it works fine.

image

System Info

  • vite version: 2.0.0-beta.23
  • Operating System: Windows 10
  • Node version: v12.16.2
  • Package manager (npm/yarn/pnpm) and version: yarn

Logs (Optional if provided reproduction)

$ vite build --debug
  vite:config bundled config file loaded in 143ms +0ms
  vite:config using resolved config: {
  vite:config   plugins: [
  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     'react-refresh',
  vite:config     'vite:css-post',
  vite:config     'vite:build-html',
  vite:config     'commonjs',
  vite:config     'vite:data-uri',
  vite:config     'vite:define',
  vite:config     'rollup-plugin-dynamic-import-variables',
  vite:config     'vite:import-analysis',
  vite:config     'vite:esbuild-transpile',
  vite:config     'vite:terser',
  vite:config     'vite:size'
  vite:config   ],
  vite:config   alias: [
  vite:config     {
  vite:config       find: /^\/@vite\//,
  vite:config       replacement: 'C:\\Users\\sib\\Desktop\\dev\\vite-project-react\\node_modules\\vite\\dist\\client/'
  vite:config     },
  vite:config     { find: 'vue', replacement: 'reactivue' },
  vite:config     { find: '@vue/runtime-dom', replacement: 'reactivue' }
  vite:config   ],
  vite:config   optimizeDeps: { exclude: [ '@vue/reactivity' ] },
  vite:config   build: {
  vite:config     base: '/',
  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     manifest: false,
  vite:config     lib: false,
  vite:config     ssr: false
  vite:config   },
  vite:config   configFile: '/Users/sib/Desktop/dev/vite-project-react/vite.config.ts',
  vite:config   inlineConfig: {
  vite:config     root: undefined,
  vite:config     mode: undefined,
  vite:config     configFile: undefined,
  vite:config     logLevel: undefined,
  vite:config     build: {}
  vite:config   },
  vite:config   root: '/Users/sib/Desktop/dev/vite-project-react',
  vite:config   command: 'build',
  vite:config   mode: 'production',
  vite:config   isProduction: true,
  vite:config   optimizeCacheDir: '\\Users\\sib\\Desktop\\dev\\vite-project-react\\node_modules\\.vite',
  vite:config   server: {},
  vite:config   env: { BASE_URL: '/', MODE: 'production', DEV: false, PROD: true },
  vite:config   assetsInclude: [Function: assetsInclude],
  vite:config   logger: {
  vite:config     info: [Function: info],
  vite:config     warn: [Function: warn],
  vite:config     error: [Function: error],
  vite:config     clearScreen: [Function: clearScreen]
  vite:config   }
  vite:config } +6ms
building for production...
[vite:resolve] Missing "." export in "reactivue" package
error during build:
Error: Missing "." export in "reactivue" package
    at bail (C:\Users\sib\Desktop\dev\vite-project-react\node_modules\vite\dist\node\chunks\dep-478c65b9.js:39770:8)
    at resolve$1 (C:\Users\sib\Desktop\dev\vite-project-react\node_modules\vite\dist\node\chunks\dep-478c65b9.js:39846:10)
    at resolveExports (C:\Users\sib\Desktop\dev\vite-project-react\node_modules\vite\dist\node\chunks\dep-478c65b9.js:39852:12)
    at resolvePackageEntry (C:\Users\sib\Desktop\dev\vite-project-react\node_modules\vite\dist\node\chunks\dep-478c65b9.js:40126:22)
    at tryNodeResolve (C:\Users\sib\Desktop\dev\vite-project-react\node_modules\vite\dist\node\chunks\dep-478c65b9.js:40041:11)
    at Object.resolveId (C:\Users\sib\Desktop\dev\vite-project-react\node_modules\vite\dist\node\chunks\dep-478c65b9.js:39952:28)
    at C:\Users\sib\Desktop\dev\vite-project-react\node_modules\rollup\dist\shared\rollup.js:18781:25
    at processTicksAndRejections (internal/process/task_queues.js:97:5)
error Command failed with exit code 1.
info Visit https://yarnpkg.com/en/docs/cli/run for documentation about this command.
@yyx990803
Copy link
Member

yyx990803 commented Jan 12, 2021

This is the correct behavior. When exports field is present, it means anything not explicitly listed inside is not exposed. This should be fixed on reactivue's side by adding . in exports.

Note exports is not an optional addition. Once it's used, modern bundlers and Node.js will prioritize it over everything else, so it must be declared correctly.

@benmccann
Copy link
Collaborator

In the case of reactivue, which this issue was originally filed for, it was a bad package configuration. However, typically when I've seen this issue hit it's because of what I'd consider a bug in Vite. Some packages like Firebase legitimately don't have . as an entry point. However, Vite always tries to resolve . instead of whatever entry point the application code is using causing this failure. See #4425 for more details

@github-actions github-actions bot locked and limited conversation to collaborators Sep 17, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants