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

@internationalized/date β€” invalid sourcemaps for *.mjs files from v3.5.3 #6367

Closed
oedotme opened this issue May 12, 2024 · 0 comments Β· Fixed by #6368
Closed

@internationalized/date β€” invalid sourcemaps for *.mjs files from v3.5.3 #6367

oedotme opened this issue May 12, 2024 · 0 comments Β· Fixed by #6368

Comments

@oedotme
Copy link
Contributor

oedotme commented May 12, 2024

Provide a general summary of the issue here

Since v3.5.3, most of *.mjs files (perhaps all except import.mjs), point to non-existing source maps.

πŸ€” Expected Behavior?

  1. utils.mjs should contain a sourceMappingURL pointing to utils.module.js.map file:
dist/utils.main.js
dist/utils.main.js.map
dist/utils.mjs            //# sourceMappingURL=utils.module.js.map
dist/utils.module.js
dist/utils.module.js.map
  1. Or utils.mjs.map to be generated during build:
dist/utils.main.js
dist/utils.main.js.map
dist/utils.mjs            //# sourceMappingURL=utils.mjs.map
dist/utils.mjs.map        // ←
dist/utils.module.js
dist/utils.module.js.map

😯 Current Behavior

As an example, utils.mjs contains a sourceMappingURL pointing to a non-existing file utils.mjs.map

dist/utils.main.js
dist/utils.main.js.map
dist/utils.mjs            //# sourceMappingURL=utils.mjs.map
dist/utils.module.js
dist/utils.module.js.map

πŸ’ Possible Solution

As mentioned in the expected behavior (1), sourceMappingURL for *.mjs files could point to the corresponding *.module.js.map files.

It seems also that import.mjs points to an "existing" sourcmaps when it's copied from module.js only because the regex pattern doesn't match sourceMappingURL=module.js.map but matches sourceMappingURL=*.module.js.map files:

let regex = /(.*)\.module\.js/g;
if (fs.existsSync(`${pkg}/dist/module.js`)) {
let js = fs.readFileSync(`${pkg}/dist/module.js`, 'utf8');
js = js.replace(regex, '$1.mjs');
fs.writeFileSync(`${pkg}/dist/import.mjs`, js);
}
for (let file of glob.sync(`${pkg}/dist/*.module.js`)) {
let js = fs.readFileSync(file, 'utf8');
js = js.replace(regex, '$1.mjs');
fs.writeFileSync(file.replace(regex, '$1.mjs'), js);
}


If that's a possible solution, the regex can be updated to exclude .map matches to preserve the sourceMappingURL:

-      let regex = /(.*)\.module\.js/g;
+      let regex = /(.*)\.module\.js(?!.map)/g;

Update: PR with this change #6368

πŸ”¦ Context

No response

πŸ–₯️ Steps to Reproduce

N/A

Version

@internationalized/date@3.5.3

What browsers are you seeing the problem on?

Chrome

If other, please specify.

No response

What operating system are you using?

macOS

🧒 Your Company/Team

No response

πŸ•· Tracking Issue

No response

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

Successfully merging a pull request may close this issue.

1 participant