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

Failed to parse source map #828

Closed
creage opened this issue Dec 16, 2021 · 11 comments
Closed

Failed to parse source map #828

creage opened this issue Dec 16, 2021 · 11 comments
Labels
help wanted Extra attention is needed

Comments

@creage
Copy link

creage commented Dec 16, 2021

Using zod: 3.11.6

We are having warning in index.mjs

WARNING in ./node_modules/zod/lib/index.mjs
Module Warning (from ./node_modules/source-map-loader/dist/cjs.js):
Failed to parse source map from 'C:\repos\Git\WorkZone\WZ-Teams\Source\tabs\node_modules\zod\src\types.ts' file: Error: ENOENT: no such file or directory, open 'C:\repos\Git\WorkZone\WZ-Teams\Source\tabs\node_modules\zod\src\types.ts'

apparently the referenced src\types.ts is not shipped with package, leading to such error.

@ingro
Copy link

ingro commented Dec 20, 2021

Can confirm that too, the index.mjs.map references files in the src folder

@scotttrinh
Copy link
Collaborator

PRs welcome to fix this in a way that is consistent with what other libraries provide here. I'm not personally very familiar with common practice in this regard.

@scotttrinh scotttrinh added the help wanted Extra attention is needed label Dec 21, 2021
@adnan-sheikh
Copy link

Even i'm getting same errors.

@jer-sen
Copy link

jer-sen commented Dec 27, 2021

Same issue here, don't known how to fix that. Issue with build script?

@evantrimboli
Copy link
Contributor

evantrimboli commented Dec 30, 2021

I'm having the same issue. For reference, this has been discussed before: #20

I'm using CRA and it doesn't offer the option to configure the source-map-loader.

@colinhacks
Copy link
Owner

Can someone make a reproduction repo and share a link here? Issues with modules/imports such as this one require a lot of detail to reproduce: your language JS vs TS, module system (package.json "module" field value), Node version, bundler + version, etc. It easiest for maintainers to start with a rep we can use to reproduce.

@PawelJ-PL
Copy link

I've prepared basic example (based on Create React App): https://github.com/PawelJ-PL/zod_issue_828. The only change is that I added zod: PawelJ-PL/zod_issue_828@b43f7d9.

Just run yarn start or yarn build

@zerosheepmoo
Copy link

zerosheepmoo commented Jan 4, 2022

Hello, especially to CRA user.

I don't know why but zod is not going well with react-scripts 5.x.x.
so, I changed it to 4.0.3 and it works well!

Till the zod developer team resolve this issue, it is needed to config manually when do CRA :)

{
...
   "dependencies": {
      ...
      "react-scripts": "4.0.3",
      ...
   },
...
}

@PawelJ-PL
Copy link

react-scripts 5.0.0 introduced Webpack 5, so it's probably reason. As temporary workaround I disabled generating source map in my project (GENERATE_SOURCEMAP=false) so I didn't need do downgrade react-scripts

Luke-zhang-04 added a commit to Luke-zhang-04/zod that referenced this issue Jan 18, 2022
@alspdx
Copy link

alspdx commented Jan 19, 2022

react-scripts 5.0.0 introduced Webpack 5, so it's probably reason.

react-scripts 5.0.0 also adds source-map-loader to the Webpack configuration, which is where this error is originating. It is possible to configure Webpack to ignore warnings but that might not be the best default configuration for CRA. Looks like #864 will take care of it.

@colinhacks
Copy link
Owner

For the moment I removed source maps. Shipping ts files in the bundle isn't a great solution - it bloats the bundle and causes issues with certain build pipelines.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
help wanted Extra attention is needed
Projects
None yet
Development

Successfully merging a pull request may close this issue.

10 participants