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
Fix passing filename from @babel/core
to @babel/parser
#15911
Open
nicolo-ribaudo
wants to merge
8
commits into
babel:main
Choose a base branch
from
nicolo-ribaudo:fix-passing-filename-to-parser
base: main
Could not load branches
Branch not found: {{ refName }}
Could not load tags
Nothing to show
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
+374
−12
Open
Changes from all commits
Commits
Show all changes
8 commits
Select commit
Hold shift + click to select a range
3fd6f52
Fix passing filename from `@babel/core` to `@babel/parser`
nicolo-ribaudo 6777110
Use relative filename
nicolo-ribaudo 8b61443
Update snapshot
nicolo-ribaudo 4ac75e8
Update test (WRONG)
nicolo-ribaudo 82cc0e0
Pass relative filename to generator also
nicolo-ribaudo a5e38f9
Fix behavior with sourceRoot
nicolo-ribaudo 0505343
Fix mappings generation
nicolo-ribaudo 18fb9a8
Add TODO comment
nicolo-ribaudo File filter
Filter by extension
Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -648,14 +648,14 @@ describe("api", function () { | |
}); | ||
}); | ||
|
||
it("default source map filename", function () { | ||
return transformAsync("var a = 10;", { | ||
it("default source map filename", async function () { | ||
const result = await transformAsync("var a = 10;", { | ||
cwd: "/some/absolute", | ||
filename: "/some/absolute/file/path.js", | ||
sourceMaps: true, | ||
}).then(function (result) { | ||
expect(result.map.sources).toEqual(["path.js"]); | ||
}); | ||
|
||
expect(result.map.sources).toEqual(["file/path.js"]); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I'm not sure if we should consider this PR as breaking because of this change, or as a bugfix. I'm not even sure if this is correct, but it's probably the best we can do given that we do not know the final location of the source map on disk. |
||
}); | ||
|
||
it("code option false", function () { | ||
|
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The plugin
babel-plugin-bundled-import-meta
is relying on this option to get the complete input filename,https://github.com/cfware/babel-plugin-bundled-import-meta/blob/master/index.js#L67
We reverted the change in #13732, we will probably have to defer this PR to Babel 8.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We could keep passing
sourceFileName
to avoid breaking plugins that rely on it -- given that it's ignored by@babel/parser
, there is no harm in doing so.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If we start to pass both base filename as
sourceFilename
for source map correctness, and complete filename assourceFileName
for legacy compatibility, that would be indeed confusing. The parser docs should then clarify thatsourceFileName
is deprecated and we offer a transition strategy, maybe a new property in theFile
class offered by@babel/core
?