RFC: Moving from Magic Comments to Import Attributes #8396
chenjiahan
started this conversation in
RFC
Replies: 1 comment 2 replies
-
Not sure if the spec allows it, but can the prefix or whole attribute name be configured by the configuration on the user end? |
Beta Was this translation helpful? Give feedback.
2 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
Summary
This RFC proposes to provide a modern API for webpack's magic comments in favor of Import Attributes for dynamic import. This change aims to align with ECMAScript standards and reduce "magic".
Motivation
Currently, Rspack uses webpack's magic comments to configure dynamic imports:
This approach has several drawbacks:
Proposal
I propose adopting Import Attributes (currently Stage 4) as the standard way to configure dynamic imports:
Backwards Compatibility
Magic comments will continue to work for a long time as we want to maintain compatibility with webpack.
Benefits
Supported Attributes
The following magic comments would be mapped to Import Attributes:
Alternatives
If webpack also implements this proposal and we want to maintain interoperability, we have the following alternatives:
webpack
prefix (Looks a bit weird in Rspack)Beta Was this translation helpful? Give feedback.
All reactions