herberttn / vite-plugin-typescript-transform

Applies the TypeScript compiler during vite's transform build phase.
MIT License
16 stars 2 forks source link

Sourcemap is likely to be incorrect: a plugin (vite-plugin-typescript-transform) was used to transform files, but didn't generate a sourcemap for the transformation #4

Open Verthon opened 6 months ago

Verthon commented 6 months ago

Hi, we are using following setup in vite-config to generate source-maps:

plugins: [
tsconfigPaths(),
    vitePluginTypescriptTransform({
      enforce: 'pre',
      filter: {
        files: {
          include: /\.ts$/,
        },
      },
    }),
]
build: {
    outDir: 'dist',
    minify: false,
    sourcemap: true,
    rollupOptions: {
      preserveEntrySignatures: 'strict',
      input: {
        index: 'src/index.ts',
      },
      output: [
        {
          dir: 'dist/esm',
          format: 'esm',
          preserveModules: true,
          preserveModulesRoot: 'src',
          entryFileNames: ({ name: fileName }) => `${fileName}.js`,
        },
        {
          dir: 'dist/cjs',
          format: 'cjs',
          entryFileNames: ({ name: fileName }) => `${fileName}.cjs`,
        },
      ],
      external: (id) => peerDeps.includes(id),
    },
  },

When using build command we run into warning inside of the terminal:

[plugin vite-plugin-typescript-transform] Sourcemap is likely to be incorrect: a plugin (vite-plugin-typescript-transform) was used to transform files, but didn't generate a sourcemap for the transformation. Consult the plugin documentation for help

Versions that we use on Node 18:

{
"typescript": "5.4.5",
"vite-plugin-typescript-transform": "1.3.0",
"vite-tsconfig-paths": "4.3.2",
"vite": "5.2.11",
}

Please let me know if you need a minimal reproducible example. Thanks

shakiba commented 1 week ago

I also see a similar error and the build produce an empty sourcemap file.

[plugin vite-plugin-typescript-transform] Sourcemap is likely to be incorrect: a plugin (vite-plugin-typescript-transform) was used to transform files, but didn't generate a sourcemap for the transformation. Consult the plugin documentation for help

herberttn commented 1 week ago

@Verthon @shakiba can either of you create a reproducible example? The projects I have here do not generate this error. Thank you!