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

Problematic Source maps #18

Open
char0n opened this issue Jan 10, 2022 · 0 comments
Open

Problematic Source maps #18

char0n opened this issue Jan 10, 2022 · 0 comments

Comments

@char0n
Copy link

char0n commented Jan 10, 2022

Description

I've detected problematic usage of source maps from @jsdevtools/[email protected]. Issue is manifesting when using for example Create React App to build the application using @jsdevtools/[email protected] as an npm package. I've inspected the source maps and according to my understanding the problem is that the source maps are missing sourcesContent field. This field should only be omitted if the tool using the source map can retrieve the sources via url or from the filesystem. Obviously this is not the case as the original source code under (src/ directory) is not part of npm distribution.

Expected result

No warning when bundling the @jsdevtools/ono using Create React App.

Actual result

Warnings like these are being emitted by the webpack@5:

Failed to parse source map from '/home/char0n/Documents/GitHub/test/node_modules/@jsdevtools/ono/src/constructor.ts' file: Error: ENOENT: no such file or directory, open '/home/char0n/Documents/GitHub/test/node_modules/@jsdevtools/ono/src/constructor.ts'

Failed to parse source map from '/home/char0n/Documents/GitHub/test/node_modules/@jsdevtools/ono/src/extend-error.ts' file: Error: ENOENT: no such file or directory, open '/home/char0n/Documents/GitHub/test/node_modules/@jsdevtools/ono/src/extend-error.ts'

Failed to parse source map from '/home/char0n/Documents/GitHub/test/node_modules/@jsdevtools/ono/src/index.ts' file: Error: ENOENT: no such file or directory, open '/home/char0n/Documents/GitHub/test/node_modules/@jsdevtools/ono/src/index.ts'

Steps to reproduce

I can create a repo demonstrating CRA@5 + @jsdevtools/[email protected] as StR POC.

Troubleshooting

CRA can be ejected, webpack.config.js edited and libraries can be excluded from source map processing:

      strictExportPresence: true,
      rules: [
        // Handle node_modules packages that contain sourcemaps
        shouldUseSourceMap && {
          enforce: 'pre',
          exclude: [
            /@babel(?:\/|\\{1,2})runtime/,
            /@jsdevtools\/ono/,
          ],
          test: /\.(js|mjs|jsx|ts|tsx|css)$/,
          loader: require.resolve('source-map-loader'),
        },
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant