dcastil/tailwind-merge

Failed to parse source map from

Closed this issue · 5 comments

happened when build in jenkins

Treating warnings as errors because process.env.CI = true.
Most CI servers set it automatically.

Failed to compile.

Failed to parse source map from '/xxx/node_modules/.pnpm/tailwind-merge@2.5.3/node_modules/src/lib/class-group-utils.ts' file: Error: ENOENT: no such file or directory, open '/xxx/node_modules/.pnpm/tailwind-merge@2.5.3/node_modules/src/lib/class-group-utils.ts'

Failed to parse source map from '/xxx/node_modules/.pnpm/tailwind-merge@2.5.3/node_modules/src/lib/config-utils.ts' file: Error: ENOENT: no such file or directory, open '/xxx/node_modules/.pnpm/tailwind-merge@2.5.3/node_modules/src/lib/config-utils.ts'

I have had these warnings start now when running in dev mode with craco start

WARNING in ./node_modules/.pnpm/tailwind-merge@2.5.3/node_modules/tailwind-merge/dist/bundle-mjs.mjs
Module Warning (from ./node_modules/.pnpm/source-map-loader@3.0.2_webpack@5.95.0/node_modules/source-map-loader/dist/cjs.js):
Failed to parse source map from '<project_path>/node_modules/.pnpm/tailwind-merge@2.5.3/node_modules/src/lib/class-group-utils.ts' file: Error: ENOENT: no such file or directory, open '<project_path>/node_modules/.pnpm/tailwind-merge@2.5.3/node_modules/src/lib/class-group-utils.ts'

WARNING in ./node_modules/.pnpm/tailwind-merge@2.5.3/node_modules/tailwind-merge/dist/bundle-mjs.mjs
Module Warning (from ./node_modules/.pnpm/source-map-loader@3.0.2_webpack@5.95.0/node_modules/source-map-loader/dist/cjs.js):
Failed to parse source map from '<project_path>/node_modules/.pnpm/tailwind-merge@2.5.3/node_modules/src/lib/config-utils.ts' file: Error: ENOENT: no such file or directory, open '<project_path>/node_modules/.pnpm/tailwind-merge@2.5.3/node_modules/src/lib/config-utils.ts'

WARNING in ./node_modules/.pnpm/tailwind-merge@2.5.3/node_modules/tailwind-merge/dist/bundle-mjs.mjs
Module Warning (from ./node_modules/.pnpm/source-map-loader@3.0.2_webpack@5.95.0/node_modules/source-map-loader/dist/cjs.js):
Failed to parse source map from '<project_path>/node_modules/.pnpm/tailwind-merge@2.5.3/node_modules/src/lib/create-tailwind-merge.ts' file: Error: ENOENT: no such file or directory, open '<project_path>/node_modules/.pnpm/tailwind-merge@2.5.3/node_modules/src/lib/create-tailwind-merge.ts'

...

Adding this to craco.config.js has silenced the warnings for me:

      webpackConfig.ignoreWarnings = [
        {
          module: /tailwind-merge/,
          message: /Failed to parse source map/,
        },
      ];

I have this same sort of issue in a mono-repo setup. The sub-package is trying to link to a source in the root node_modules like so:
"../../../../../../node_modules/src/lib/class-group-utils.ts"
but it is missing "tailwind-merge":
"../../../../../../node_modules/tailwind-merge/src/lib/class-group-utils.ts"

I solved this problem by modifying the webpach configuration.
Is the problem because tailwind-merge does not give a.map file?

 module: {
      strictExportPresence: true,
      rules: [
        // Handle node_modules packages that contain sourcemaps
        shouldUseSourceMap && {
          enforce: 'pre',
          exclude: [/@babel(?:\/|\\{1,2})runtime/, /node_modules/], //  modify here , add /node_modules/
          test: /\.(js|mjs|jsx|ts|tsx|css)$/,
          loader: require.resolve('source-map-loader'),
        },

Hey @vaynevayne and everyone else! 👋

Just checked tailwind-merge@2.5.3 and there the source maps indeed seem to be linking incorrectly.

E.g. in the file tailwind-merge/dist/bundle-mjs.mjs.map I see paths like ../../src/lib/class-group-utils.ts, but that's one directory too far up, it should be ../src/lib/class-group-utils.ts. This was still correct in v2.5.2.

I'll fix this.

This was addressed in release v2.5.4.