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

Vite Build 4.1.4 import using directory breaks #12328

Closed
7 tasks done
andrei0x309 opened this issue Mar 8, 2023 · 2 comments
Closed
7 tasks done

Vite Build 4.1.4 import using directory breaks #12328

andrei0x309 opened this issue Mar 8, 2023 · 2 comments

Comments

@andrei0x309
Copy link

Describe the bug

doing an import like:
(await import(/* @vite-ignore */'highlight.js/es/core'/* @vite-ignore */)).default;
worked in 4.0.4 but it breaks in 4.1.4( after I updated the vite pkg)

Reproduction

https://github.com/andrei0x309/vite-4.1.4-import

Steps to reproduce

Run:
yarn install
yarn build

System Info

System:
    OS: Windows 10 10.0.19045
    CPU: (16) x64 AMD Ryzen 7 3700X 8-Core Processor
    Memory: 10.20 GB / 27.93 GB
  Binaries:
    Node: 18.13.0 - C:\Program Files\nodejs\node.EXE
    Yarn: 1.22.18 - ~\AppData\Local\Yarn\bin\yarn.CMD
    npm: 8.0.0 - ~\AppData\Roaming\npm\npm.CMD
  Browsers:
    Chrome: 110.0.5481.178
    Edge: Spartan (44.19041.1266.0), Chromium (110.0.1587.63)
    Internet Explorer: 11.0.19041.1566
  npmPackages:
    vite: 4.1.4 => 4.1.4

Used Package Manager

yarn

Logs

Click to expand!
K:\dev\projects\contrib\bugs\vite-4.1.4-import\node_modules\.bin\vite build --debug
  vite:config bundled config file loaded in 29.62ms +0ms
  vite:esbuild init tsconfck (root: K:/dev/projects/contrib/bugs/vite-4.1.4-import) +0ms
  vite:esbuild init tsconfck (root: K:/dev/projects/contrib/bugs/vite-4.1.4-import) +1ms
  vite:esbuild init tsconfck (root: K:/dev/projects/contrib/bugs/vite-4.1.4-import) +1ms
  vite:esbuild init tsconfck (root: K:/dev/projects/contrib/bugs/vite-4.1.4-import) +1ms
  vite:esbuild init tsconfck end +1ms
  vite:esbuild init tsconfck end +0ms
  vite:esbuild init tsconfck end +1ms
  vite:esbuild init tsconfck end +0ms
  vite:config using resolved config: {
  vite:config   server: {
  vite:config     preTransformRequests: true,
  vite:config     port: 5512,
  vite:config     middlewareMode: false,
  vite:config     fs: { strict: true, allow: [Array], deny: [Array] }
  vite:config   },
  vite:config   optimizeDeps: {
  vite:config     disabled: 'build',
  vite:config     force: undefined,
  vite:config     esbuildOptions: { preserveSymlinks: false }
  vite:config   },
  vite:config   build: {
  vite:config     target: [ 'es2020', 'edge88', 'firefox78', 'chrome87', 'safari14' ],
  vite:config     cssTarget: [ 'es2020', 'edge88', 'firefox78', 'chrome87', 'safari14' ],
  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     minify: 'esbuild',
  vite:config     terserOptions: {},
  vite:config     write: true,
  vite:config     emptyOutDir: null,
  vite:config     copyPublicDir: true,
  vite:config     manifest: false,
  vite:config     lib: false,
  vite:config     ssr: false,
  vite:config     ssrManifest: false,
  vite:config     ssrEmitAssets: false,
  vite:config     reportCompressedSize: true,
  vite:config     chunkSizeWarningLimit: 500,
  vite:config     watch: null,
  vite:config     commonjsOptions: { include: [Array], extensions: [Array] },
  vite:config     dynamicImportVarsOptions: { warnOnError: true, exclude: [Array] },
  vite:config     modulePreload: { polyfill: true }
  vite:config   },
  vite:config   configFile: 'K:/dev/projects/contrib/bugs/vite-4.1.4-import/vite.config.js',
  vite:config   configFileDependencies: [ 'K:/dev/projects/contrib/bugs/vite-4.1.4-import/vite.config.js' ],
  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     optimizeDeps: { force: undefined },
  vite:config     build: {}
  vite:config   },
  vite:config   root: 'K:/dev/projects/contrib/bugs/vite-4.1.4-import',
  vite:config   base: '/',
  vite:config   rawBase: '/',
  vite:config   resolve: {
  vite:config     mainFields: [ 'module', 'jsnext:main', 'jsnext' ],
  vite:config     browserField: true,
  vite:config     conditions: [],
  vite:config     extensions: [
  vite:config       '.mjs',  '.js',
  vite:config       '.mts',  '.ts',
  vite:config       '.jsx',  '.tsx',
  vite:config       '.json'
  vite:config     ],
  vite:config     dedupe: [],
  vite:config     preserveSymlinks: false,
  vite:config     alias: [ [Object], [Object] ]
  vite:config   },
  vite:config   publicDir: 'K:\\dev\\projects\\contrib\\bugs\\vite-4.1.4-import\\public',
  vite:config   cacheDir: 'K:/dev/projects/contrib/bugs/vite-4.1.4-import/node_modules/.vite',
  vite:config   command: 'build',
  vite:config   mode: 'production',
  vite:config   ssr: {
  vite:config     format: 'esm',
  vite:config     target: 'node',
  vite:config     optimizeDeps: { disabled: true, esbuildOptions: [Object] }
  vite:config   },
  vite:config   isWorker: false,
  vite:config   mainConfig: null,
  vite:config   isProduction: true,
  vite:config   plugins: [
  vite:config     'vite:build-metadata',
  vite:config     'vite:pre-alias',
  vite:config     'alias',
  vite:config     'vite:modulepreload-polyfill',
  vite:config     'vite:resolve',
  vite:config     'vite:html-inline-proxy',
  vite:config     'vite:css',
  vite:config     'vite:esbuild',
  vite:config     'vite:json',
  vite:config     'vite:wasm-helper',
  vite:config     'vite:worker',
  vite:config     'vite:asset',
  vite:config     'vite:wasm-fallback',
  vite:config     'vite:define',
  vite:config     'vite:css-post',
  vite:config     'vite:build-html',
  vite:config     'vite:worker-import-meta-url',
  vite:config     'vite:asset-import-meta-url',
  vite:config     'vite:force-systemjs-wrap-complete',
  vite:config     'vite:watch-package-data',
  vite:config     'commonjs',
  vite:config     'vite:data-uri',
  vite:config     'vite:dynamic-import-vars',
  vite:config     'vite:import-glob',
  vite:config     'vite:build-import-analysis',
  vite:config     'vite:esbuild-transpile',
  vite:config     'vite:terser',
  vite:config     'vite:reporter',
  vite:config     'vite:load-fallback'
  vite:config   ],
  vite:config   preview: {
  vite:config     port: undefined,
  vite:config     strictPort: undefined,
  vite:config     host: undefined,
  vite:config     https: undefined,
  vite:config     open: undefined,
  vite:config     proxy: undefined,
  vite:config     cors: undefined,
  vite:config     headers: undefined
  vite:config   },
  vite:config   env: { BASE_URL: '/', MODE: 'production', DEV: false, PROD: true },
  vite:config   assetsInclude: [Function: assetsInclude],
  vite:config   logger: {
  vite:config     hasWarned: false,
  vite:config     info: [Function: info],
  vite:config     warn: [Function: warn],
  vite:config     warnOnce: [Function: warnOnce],
  vite:config     error: [Function: error],
  vite:config     clearScreen: [Function: clearScreen],
  vite:config     hasErrorLogged: [Function: hasErrorLogged]
  vite:config   },
  vite:config   packageCache: Map(0) { set: [Function (anonymous)] },
  vite:config   createResolver: [Function: createResolver],
  vite:config   worker: {
  vite:config     format: 'iife',
  vite:config     plugins: [
  vite:config       'vite:build-metadata',
  vite:config       'vite:pre-alias',
  vite:config       'alias',
  vite:config       'vite:modulepreload-polyfill',
  vite:config       'vite:resolve',
  vite:config       'vite:html-inline-proxy',
  vite:config       'vite:css',
  vite:config       'vite:esbuild',
  vite:config       'vite:json',
  vite:config       'vite:wasm-helper',
  vite:config       'vite:worker',
  vite:config       'vite:asset',
  vite:config       'vite:wasm-fallback',
  vite:config       'vite:define',
  vite:config       'vite:css-post',
  vite:config       'vite:build-html',
  vite:config       'vite:worker-import-meta-url',
  vite:config       'vite:asset-import-meta-url',
  vite:config       'vite:force-systemjs-wrap-complete',
  vite:config       'vite:watch-package-data',
  vite:config       'commonjs',
  vite:config       'vite:data-uri',
  vite:config       'vite:dynamic-import-vars',
  vite:config       'vite:import-glob',
  vite:config       'vite:build-import-analysis',
  vite:config       'vite:esbuild-transpile',
  vite:config       'vite:terser',
  vite:config       'vite:load-fallback'
  vite:config     ],
  vite:config     rollupOptions: {},
  vite:config     getSortedPlugins: [Function: getSortedPlugins],
  vite:config     getSortedPluginHooks: [Function: getSortedPluginHooks]
  vite:config   },
  vite:config   appType: 'spa',
  vite:config   experimental: { importGlobRestoreExtension: false, hmrPartialAccept: false },
  vite:config   getSortedPlugins: [Function: getSortedPlugins],
  vite:config   getSortedPluginHooks: [Function: getSortedPluginHooks]
  vite:config } +18ms
vite v4.1.4 building for production...
✓ 3 modules transformed.
[commonjs--resolver] Missing "./es/core" specifier in "highlight.js" package
error during build:
Error: Missing "./es/core" specifier in "highlight.js" package
    at e (file:///K:/dev/projects/contrib/bugs/vite-4.1.4-import/node_modules/vite/dist/node/chunks/dep-ca21228b.js:14845:25)
    at n (file:///K:/dev/projects/contrib/bugs/vite-4.1.4-import/node_modules/vite/dist/node/chunks/dep-ca21228b.js:14845:627)
    at o (file:///K:/dev/projects/contrib/bugs/vite-4.1.4-import/node_modules/vite/dist/node/chunks/dep-ca21228b.js:14845:1276)
    at resolveExports (file:///K:/dev/projects/contrib/bugs/vite-4.1.4-import/node_modules/vite/dist/node/chunks/dep-ca21228b.js:22033:20)
    at resolveDeepImport (file:///K:/dev/projects/contrib/bugs/vite-4.1.4-import/node_modules/vite/dist/node/chunks/dep-ca21228b.js:22052:31)
    at tryNodeResolve (file:///K:/dev/projects/contrib/bugs/vite-4.1.4-import/node_modules/vite/dist/node/chunks/dep-ca21228b.js:21737:20)
    at Object.resolveId (file:///K:/dev/projects/contrib/bugs/vite-4.1.4-import/node_modules/vite/dist/node/chunks/dep-ca21228b.js:21488:28)
    at file:///K:/dev/projects/contrib/bugs/vite-4.1.4-import/node_modules/rollup/dist/es/shared/node-entry.js:24196:40
    at process.processTicksAndRejections (node:internal/process/task_queues:95:5)
    at async PluginDriver.hookFirstAndGetPlugin (file:///K:/dev/projects/contrib/bugs/vite-4.1.4-import/node_modules/rollup/dist/es/shared/node-entry.js:24096:28)
error Command failed with exit code 1.
info Visit https://yarnpkg.com/en/docs/cli/run for documentation about this command.

Validations

@fi3ework
Copy link
Member

fi3ework commented Mar 8, 2023

Affect by #11259.
Actually, in 4.0.4. 'highlight.js/es/core' should not be accessed indeed because it's not in the packagejson.exports see (https://www.npmjs.com/package/highlight.js?activeTab=explore). The current result is correct.

@andrei0x309
Copy link
Author

andrei0x309 commented Mar 8, 2023

@fi3ework
Thanks so the issue was in 4.0.4.
Changed it to /lib/core and it works.
The error is confusing for me I wasn't able to deduce from it that the export does not exist in lib package.json
I guess

Export lib-name/xxxx does not exist in lib-name/package.json

would be much clear at least for me.

@github-actions github-actions bot locked and limited conversation to collaborators Mar 23, 2023
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

2 participants