-
-
Notifications
You must be signed in to change notification settings - Fork 5.8k
Deprecate ModuleDeclaration alias
#15266
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
Deprecate ModuleDeclaration alias
#15266
Conversation
Rename ModuleDeclaration to ImportOrExportDeclaration in favor of the module declarations proposal.
|
Build successful! You can test your changes in the REPL here: https://babeljs.io/repl/build/53651/ |
nicolo-ribaudo
left a comment
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.
It seems like this PR removes ModuleDeclaration from t.FLIPPED_ALIAS_KEYS. Can we keep it until Babel 8?
2472c0d to
6911d1b
Compare
|
in version 7.21.0,i get the mistake |
|
Trace: isModuleDeclaration has been deprecated, please migrate to isImportOrExportDeclaration. |
|
Many third-party packages will automatically use the v7.21.0 version, causing too many warnings in the terminal, and can only wait for the third-party package to change. So sad! |
好了兄弟们,估计作者这会儿还在睡觉?他们那可能是晚上,我先给大家提供一个临时的解决方案,可以试试对你们是否有帮助。 |
only for yarn, can not with npm, so sad ... |
666,这个临时方案可用,强迫症表示实在无法忍受编译时出现这么一大堆编译错误,坐等插件作者更新 |
|
I'm releasing #15448 now, which should greatly reduce the number of warnings (to 1 in most cases). |
Soooo Nice, It works for me. Thanks again! |
ModuleDeclarationalias and rename toImportOrExportDeclarationIn this PR we deprecate the
ModuleDeclarationalias forImportOrExportDeclaration, due to the name conflict with the stage 2 Module Declarations proposal. TheImportOrExportDeclarationalias now covers the following AST types:We plan to deprecate the
ModuleDeclarationalias usage starting from Babel 7.21. In the next major version,ModuleDeclarationwill longer function as an alias, instead it will refer to theModuleDeclarationnodemodule foo {}, followed by theis*andassert*helpers.Migration guide (for app users)
If one of your Babel plugins is using deprecated methods, you will see errors as such:
Reading the error stack trace from top to bottom, we can find the first path that is not related to
@babel/internals, in this case, it isbabel-plugin-exampleon the third line:Now, please open a new issue to the affected Babel plugin (
babel-plugin-example) and attach this issue to plugin authors as references (The next section is migration guide for plugin authors). Before the plugin author migrates the usage, you can pin@babel/*to v7.20.Migration guide (for plugin authors)
@babel/typesusageIf
@babel/typesis independencies, bump it to^7.21.0and update the usage:@babel/coreusageIf
@babel/coreis inpeerDependenciesor you are using Plugin API injected as the first parameter of your plugin.In this case your plugin should work with both Babel < 7.21 and 7.21+
export default function (api) { const t = api.types; --- t.isModuleDeclaration(node) +++ t.isImportDeclaration(node) || t.isExportDeclaration(node) --- t.assertModuleDeclaration(node) +++ if (!t.isImportDeclaration(node) && !t.isExportDeclaration(node)) { +++ throw new Error(`Expected type "ImportOrExportDeclaration", but instead got "${node.type}".`) +++ } }Plugin visitor or traverse usage
{ visitor: { --- ModuleDeclaration(path, state) { +++ "ImportDeclaration|ExportDeclaration"(path, state) { } } }