feat: support output.esModule option#1812
Merged
hyf0 merged 35 commits intorolldown:mainfrom Aug 3, 2024
Merged
Conversation
✅ Deploy Preview for rolldown-rs canceled.
|
Member
|
I'm refactoring cjs exports generating logic to ensure the correct semantic of live binding. Related changes are going to be on hold. |
Contributor
Author
Ok. It seems that this PR doesn't have an impact on the actual export behavior :) And it's no hurry to be merged. |
…ldown into feat/namespace-block
…/namespace-block
…/namespace-block
output.esModule option and the namespace block.
output.esModule option and the namespace block.output.esModule option and the namespace marker.
output.esModule option and the namespace marker.output.esModule option
hyf0
approved these changes
Aug 3, 2024
underfin
reviewed
Aug 3, 2024
underfin
reviewed
Aug 3, 2024
underfin
reviewed
Aug 3, 2024
underfin
approved these changes
Aug 3, 2024
Contributor
|
cc @hyf0 Check assignees' approval Look like is not expected. |
Member
|
There aren't event like |
This file contains hidden or 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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
This PR introduces support for namespace blocks in IIFE or CJS format outputs, treating them as ES Modules instead of relying solely on
output.exportsbeingnamed. @underfin (I'm not in a hurry to work on this as I will likely spend a lot of time on my competition project next month. :)Modifications
determine_export_mode.render_namespace_block, inspired by Rollup, but implemented based on behavior observed in the REPL.Behaviors
output.exportsisn'tnamed.output.formatisesmorapp.esmshould always be an ES module.appwould never be a module.output.esModuleis set to'always'(ortruefor Rollup compatibility), or'if-default-prop'(similar to Rollup), it will renderObject.defineProperty(exports, '__esModule', { value: true }).generatedCode.symbolfor future updates.Rationale for Not Using
boolean | 'if-default-prop'During the conversion from JavaScript to Rust, the program encountered a panic when the source value was a boolean. Overriding
trueorfalsewith a string was considered inelegant, so this approach was not used.