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

Invalid Sourcemap #2806

Closed
6 tasks done
pikax opened this issue Mar 31, 2021 · 3 comments
Closed
6 tasks done

Invalid Sourcemap #2806

pikax opened this issue Mar 31, 2021 · 3 comments
Labels
documentation Improvements or additions to documentation

Comments

@pikax
Copy link
Contributor

pikax commented Mar 31, 2021

Describe the bug

When building with sourcemap:"hidden" some sourcemap will not be generated correctly and warning will be thrown:

vite-sourcemap-issue> yarn build
yarn run v1.22.10
warning package.json: No license field
$ vue-tsc --noEmit && vite build
vite v2.1.5 building for production...
 15 modules transformed.
rendering chunks (1)...Sourcemap is likely to be incorrect: a plugin (vite:import-analysis) was used to transform files, but didn't generate a sourcemap for the transformation. Consult the plugin documentation for help        
rendering chunks (2)...Sourcemap is likely to be incorrect: a plugin (vite:define) was used to transform files, but didn't generate a sourcemap for the transformation. Consult the plugin documentation for help
Sourcemap is likely to be incorrect: a plugin (vite:define) was used to transform files, but didn't generate a sourcemap for the transformation. Consult the plugin documentation for help
Sourcemap is likely to be incorrect: a plugin (vite:define) was used to transform files, but didn't generate a sourcemap for the transformation. Consult the plugin documentation for help
Sourcemap is likely to be incorrect: a plugin (vite:define) was used to transform files, but didn't generate a sourcemap for the transformation. Consult the plugin documentation for help
dist/assets/logo.03d6d6da.png    6.69kb
dist/index.html                  0.47kb
dist/assets/index.e108508f.css   0.34kb / brotli: 0.17kb
dist/assets/index.c52965d2.js    2.12kb / brotli: 0.92kb
dist/assets/index.c52965d2.js.map 0.10kb
dist/assets/vendor.1d2f5768.js   43.27kb / brotli: 15.59kb
dist/assets/vendor.1d2f5768.js.map 0.10kb
Done in 7.28s.

The dist/assets/index.c52965d2.js.map is broken because the file only contains

{"version":3,"file":"index.c52965d2.js","sources":[],"sourcesContent":[],"names":[],"mappings":""}

Reproduction

  • npm init @vitejs/app
  • create vue-ts or vue
  • go inside of the project folder
  • run yarn
  • go to vite.config.ts
  • add :
  build: {
    rollupOptions: {
      output: {
        sourcemap: "hidden",
        // compact: true,
      },
    },
  },
  • run yarn build

vite-sourcemap-issue.zip

System Info

Output of npx envinfo --system --npmPackages vite,@vitejs/plugin-vue --binaries --browsers:

  System:
    OS: Windows 10 10.0.21286
    CPU: (24) x64 AMD Ryzen 9 3900X 12-Core Processor
    Memory: 22.57 GB / 63.95 GB
  Binaries:
    Node: 14.16.0 - C:\Program Files\nodejs\node.EXE
    Yarn: 1.22.10 - C:\Program Files\nodejs\yarn.CMD
    npm: 6.14.11 - C:\Program Files\nodejs\npm.CMD
  Browsers:
    Edge: Spartan (44.21286.1000.0), Chromium (89.0.774.63)
    Internet Explorer: 11.0.21286.1000

Used package manager: yarn

Logs

$ yarn build --debug
yarn run v1.22.10
warning package.json: No license field
$ vue-tsc --noEmit && vite build --debug
  vite:config bundled config file loaded in 129ms +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     'vite:vue',
  vite:config     'vite:define',
  vite:config     'vite:css-post',
  vite:config     'vite:build-html',
  vite:config     'commonjs',
  vite:config     'vite:data-uri',
  vite:config     'rollup-plugin-dynamic-import-variables',
  vite:config     'vite:import-analysis',
  vite:config     'vite:esbuild-transpile',
  vite:config     'vite:terser',
  vite:config     'vite:reporter'
  vite:config   ],
  vite:config   build: {
  vite:config     target: [ 'es2019', 'edge18', '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: { output: [Object] },
  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   define: { __VUE_OPTIONS_API__: true, __VUE_PROD_DEVTOOLS__: false },
  vite:config   ssr: { external: [ 'vue', '@vue/server-renderer' ] },
  vite:config   configFile: 'C:/dev/temp/vite-sourcemap-issue/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     build: {}
  vite:config   },
  vite:config   root: 'C:/dev/temp/vite-sourcemap-issue',
  vite:config   base: '/',
  vite:config   resolve: { dedupe: undefined, alias: [ [Object] ] },
  vite:config   publicDir: 'C:\\dev\\temp\\vite-sourcemap-issue\\public',
  vite:config   command: 'build',
  vite:config   mode: 'production',
  vite:config   isProduction: true,
  vite:config   optimizeCacheDir: 'C:\\dev\\temp\\vite-sourcemap-issue\\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     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 } +6ms
vite v2.1.5 building for production...
 15 modules transformed.
rendering chunks (1)...Sourcemap is likely to be incorrect: a plugin (vite:import-analysis) was used to transform files, but didn't generate a sourcemap for the transformation. Consult the plugin documentation for help
rendering chunks (2)...Sourcemap is likely to be incorrect: a plugin (vite:define) was used to transform files, but didn't generate a sourcemap for the transformation. Consult the plugin documentation for help
Sourcemap is likely to be incorrect: a plugin (vite:define) was used to transform files, but didn't generate a sourcemap for the transformation. Consult the plugin documentation for help
Sourcemap is likely to be incorrect: a plugin (vite:define) was used to transform files, but didn't generate a sourcemap for the transformation. Consult the plugin documentation for help
Sourcemap is likely to be incorrect: a plugin (vite:define) was used to transform files, but didn't generate a sourcemap for the transformation. Consult the plugin documentation for help
dist/assets/logo.03d6d6da.png    6.69kb
dist/index.html                  0.47kb
dist/assets/index.e108508f.css   0.34kb / brotli: 0.17kb
dist/assets/index.c52965d2.js    2.12kb / brotli: 0.92kb
dist/assets/index.c52965d2.js.map 0.10kb
dist/assets/vendor.1d2f5768.js   43.27kb / brotli: 15.59kb
dist/assets/vendor.1d2f5768.js.map 0.10kb
Done in 10.39s.

Before submitting the issue, please make sure you do the following

  • Read the Contributing Guidelines.
  • Read the docs.
  • Check that there isn't already an issue that reports the same bug to avoid creating a duplicate.
  • Provide a description in this issue that describes the bug.
  • Make sure this is a Vite issue and not a framework-specific issue. For example, if it's a Vue SFC related bug, it should likely be reported to https://github.com/vuejs/vue-next instead.
  • Check that this is a concrete bug. For Q&A open a GitHub Discussion or join our Discord Chat Server.
@pikax
Copy link
Contributor Author

pikax commented Apr 1, 2021

This issue is caused by using the build.rollupOptions.output.sourcemap instead of vite build.soucemap

Vite should throw an warning mentioning the use of build.rollupOptions.output.sourcemap

Thanks to @antfu for figuring it out :)

@antfu antfu added documentation Improvements or additions to documentation and removed pending triage labels Apr 1, 2021
@franck-lynn
Copy link

build: {
        rollupOptions: {
            output: {
                sourcemap: "hidden"
            }
        }
    },
build: {
    sourceMap: "inline"  
}

I test above , but can't got the source-map in .vite

@bluwy
Copy link
Member

bluwy commented Dec 29, 2022

I don't think we need to throw a warning if rollupOptions is used to configure sourcemaps instead. I think it's already clear how sourcemaps can be configured following the docs.

@bluwy bluwy closed this as not planned Won't fix, can't repro, duplicate, stale Dec 29, 2022
@github-actions github-actions bot locked and limited conversation to collaborators Jan 13, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
documentation Improvements or additions to documentation
Projects
None yet
Development

No branches or pull requests

4 participants