-
Notifications
You must be signed in to change notification settings - Fork 2.8k
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
[Bug]: commonjs source-maps sources
point to .js
and cjs files contain duplicated sourceMappingURL
#27320
Comments
sourceMappingURL
sourceMappingURL
sourceMappingURL
sources
point to .js
and cjs files contain duplicated sourceMappingURL
It's clearly SWC bug: https://codesandbox.io/p/sandbox/funny-wildflower-wnxf1b $ npx swc ./index.js -o output.esm.js --config module.type=es6 --source-maps=true ⬇️⬇️⬇️ import path from "path";
console.log("Hello CodeSandbox", path.dirname("./foo/bar.js"));
//# sourceMappingURL=output.esm.js.map $ npx swc ./output.esm.js -o output.cjs.js --config module.type=commonjs --source-maps=true ⬇️⬇️⬇️ "use strict";
Object.defineProperty(exports, "__esModule", {
value: true
});
var _path = /*#__PURE__*/ _interopRequireDefault(require("path"));
function _interopRequireDefault(obj) {
return obj && obj.__esModule ? obj : {
default: obj
};
}
console.log("Hello CodeSandbox", _path.default.dirname("./foo/bar.js")); //# sourceMappingURL=output.esm.js.map
//# sourceMappingURL=output.cjs.js.map 👆"sourceMappingURL" comment is doubled |
thanks for taking additional look on this @layershifter 🙌. yeah I'm aware about this. not sure if it's a bug or rather missing feature. Babel does this like following -> checks for that source map comment, removes it as present, generates new one to provide accurate source map to transformed content. Though some users reported this as bug on babel side. SWC doesn't do what babel does, which might be missing feature ? anyways lets report this to swc folks. ty |
Because this issue has not had activity for over 180 days, we're automatically closing it for house-keeping purposes. Still require assistance? Please, create a new issue with up-to date details. |
Because this issue has not had activity for over 180 days, we're automatically closing it for house-keeping purposes. Still require assistance? Please, create a new issue with up-to date details. |
Library
React Components / v9 (@fluentui/react-components)
Are you reporting Accessibility issue?
None
Reproduction
Pre swc (using TS):
Post swc:
esm map: https://unpkg.com/@fluentui/[email protected]/lib/Body1.js.map
cjs map: https://unpkg.com/@fluentui/[email protected]/lib-commonjs/Body1.js.map
sourceMappingURL
present within the source map as wellcjs: https://unpkg.com/@fluentui/[email protected]/lib-commonjs/Body1.js
Bug Description
Actual Behavior
After migration to swc, source maps for commonjs inputs don't point to TS original source anymore.
Also the
sourceMappingURL
is being printed twice within cjs output (which is present within the source map )Expected Behavior
This regression is actually expected, but we didn't thought about it while implementing the change, as our transpilation pipeline changed
From
To
Besides the duplicated
sourceMappingURL
emit within cjs output, it shouldn't have any real impact for consumers, as we usesourcesContent
which is a source of truth for the actual source mapping.More feedback is needed.
Actionable for now is to reduce that duplicate emit for commonjs.
Logs
No response
Requested priority
Normal
Products/sites affected
No response
Are you willing to submit a PR to fix?
yes
Validations
Related issues/PRs
#27250
The text was updated successfully, but these errors were encountered: