jkbrzt / rrule

JavaScript library for working with recurrence rules for calendar dates as defined in the iCalendar RFC and more.
https://jkbrzt.github.io/rrule
Other
3.34k stars 513 forks source link

JS map file 'sources' incorrect for dist/esm files #303

Open anthwinter opened 5 years ago

anthwinter commented 5 years ago

Reporting an issue

Thank you for taking an interest in rrule! Please include the following in your report:

I am using Webpack v4 to bundle my vendor dependencies, I'm also using the Source Map Loader to extract source maps from my vendor files into one, this includes the rrule package.

I am getting warnings for each rrule 'esm' file stating it cannot find the source map, as it is trying to find it in the src directory, not the 'dist' directory.

WARNING in ./node_modules/rrule/dist/esm/weekday.js
Module Warning (from ./node_modules/source-map-loader/index.js):
(Emitted value instead of an instance of Error) Cannot find source file '../../src/weekday.ts': Error: Can't resolve '../../src/weekday.ts' in '/Users/anth/sites/mysite/node_modules/rrule/dist/esm'

If you look at one of the *.map files within the dist/esm folder of rrule, you will see that the sources point to the src directory, and this is what is causing the warnings when using the source-map-loader to try and extract all vendor mappings.

davidgoli commented 5 years ago

@anthw Thanks for the bug report! Would you be able to contribute a minimal repro test case, including a webpack.config.js with the appropriate project configuration? I'm the only active maintainer right now and it would greatly help with fixing the issue. Thanks!

anthwinter commented 5 years ago

@davidgoli Sure. I have made https://github.com/anthw/rrule-map-issue

Just run yarn to get everything installed and then npx webpack should show the errors

anthwinter commented 5 years ago

@davidgoli I have done a bit of research and I think the solution might be to add "sourceRoot": "./dist/esm" to the tsconfig.json file. I can create a PR to get this change submitted if you like? Is there anything else you would need if I do the PR?

davidgoli commented 5 years ago

Published v2.6.0.

MaximKudriavtsev commented 5 years ago

Hi @davidgoli,

I am using the rrule 2.6.0 and have the same issue.

image

In the console of the following example you can see a next warning

DevTools failed to parse SourceMap: https://zr81yovxml.codesandbox.io/node_modules/rrule/dist/es5/rrule.js.map
anthwinter commented 5 years ago

I think I must have test wrong when I thought it was working as I still get the issue as reported too. Sorry!

MaximKudriavtsev commented 5 years ago

@davidgoli any news?

joshkostal commented 4 years ago

@anthwinter This is an issue for me again, can it be reopened?

anthwinter commented 4 years ago

@joshkostal I originally created a PR #305 to fix this, which was succeeded by #310, so #305 was closed without action.

I thought #310 fixed the issue but hadn't. So maybe #305 could be looked at again @davidgoli ?

My temporary work around for this was to exclude rrule within the loader. Not great, but stops the mass of warnings.

exclude: [path.resolve(__dirname, 'node_modules/rrule')]

PatrickMcLennan commented 4 years ago

Would also love to see or help with a resolution to this. I'm currently suppressing the warnings on my webpack-dev-server using @anthwinter 's solution but would rather not have to do so if that's possible.

Seeing the same warnings as above, using rrule 2.6.4 with webpack 4.44.5 + webpack-dev-server 3.10.2

AryamnovEugeniy commented 3 years ago

I'm seeing the same warnings with rrule 2.6.6. I would also like if this issue was resolved.

bertho-zero commented 3 years ago

A release would be welcome.

RiodeJaneiroo commented 2 years ago

i have the same issue with Create React App v5 (webpack v5)

"rrule": "^2.6.8", "react-scripts": "5.0.0",

WARNING in ./node_modules/rrule/dist/esm/src/weekday.js Module Warning (from ./node_modules/source-map-loader/dist/cjs.js): Failed to parse source map from '/Users/rio/Work/edr/node_modules/rrule/src/weekday.ts' file: Error: ENOENT: no such file or directory, open '/Users/rio/Work/edr/node_modules/rrule/src/weekday.ts' @ ./node_modules/rrule/dist/esm/src/index.js 20:0-36 20:0-36 @ ./src/service/schedulesService.js 18:12-27

chunkily commented 2 years ago

Having the same issue as @RiodeJaneiroo when I tried to update a react app that uses this library to create-react-app v5.0.0.

The source-map-loader module is printing the warnings because it is not able to find the source typescript files in the node_modules folder, which shouldn't be there because only the dist files are downloaded when we do an install.

I'm not sure how this issue can be resolved save for including the typescript source files in an install or removing sourcemaps in the generated dist.

For the time being I am working around this by pointing my rrule dependency on a forked branch that disables sourcemaps.

edandersen commented 2 years ago

This needs reopening as its still an issue with react-scripts 5.0.0 and rrule 2.6.8.

@chunkily is this forked branch you mentioned public?

keyvanm commented 2 years ago

I'm having the same issue in create-react-app. Perhaps using inline source maps in the library would mitigate this issue? I had a similar problem while building a library recently, and inline sourcemaps resolved it.

In tsconfig.json under compilerOptions

{
  "compilerOptions": {
    ...
    "sourceMap": true,
    "inlineSources": true,
  },
  ...
}
Kaishley commented 2 years ago

Same issue here with

"rrule": "^2.6.8", "react-scripts": "5.0.0",

chunkily commented 2 years ago

This needs reopening as its still an issue with react-scripts 5.0.0 and rrule 2.6.8.

@chunkily is this forked branch you mentioned public?

It is indeed public. https://github.com/chunkily/rrule/tree/sourcemapless

So here are the steps I took

1) Fork the rrule repository 2) Create a new branch that disables sourcemap generation 3) Build the rrule library, and push the entire built dist/ folder to github 4) Update the dependencies in the react app's package.json to use the fork

"rrule": "chunkily/rrule#259ae356a78ae0d31a02eb4e87b3219072860abe"
davidgoli commented 2 years ago

Can someone please verify whether this still reproduces with v2.6.9? Thanks!

jkronborg commented 2 years ago

@davidgoli Unfortunately my supposed fix included in version 2.6.9 did in fact not fix this issue. My bad.

Kaishley commented 2 years ago

Any idea how to get it fixed?

chunkily commented 2 years ago

Well, I can think of a three possible solutions, but each of them has their own cons.

1) Disable sourcemaps. This might make it harder to debug any issues in production environments. 2) Inline sourcemaps. This will bloat the size of the JS output. 3) Include the typescript source files when doing an install. This will bloat the size of installs.

Kaishley commented 2 years ago

I think the easiest solution is to include the src (.ts files) folder when installing.

image

stack overflow discussion

Moinax commented 2 years ago

Isn't this fixed yet, it's been there for a month already and block us to release our application with react-scripts 5.x

louwers commented 2 years ago

Can this be re-opened?

LamOort commented 2 years ago

I'm still having this issue after upgrading react-scripts to 5.0.0.

aminsaedi commented 1 year ago

Any updates?

amadeogallardo commented 1 year ago

This error still seems to be present on v2.7.1.

mertcandonmez commented 1 year ago

I'am having the same issue. Any updates? "rrule": "2.7.1" > also tried with "rrule": "2.7.2" "react-scripts": "5.0.1"

dargmuesli commented 2 months ago

This should be resolves by PR #634.