Skip to content
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

Add `export-namespace-from` to `preset-env` #11849

Merged
merged 4 commits into from Jul 21, 2020

Conversation

@JLHwung
Copy link
Contributor

JLHwung commented Jul 17, 2020

Q                       A
Fixed Issues? Closes #11363
Minor: New Feature? Yes
Tests Added + Pass? Yes
Documentation PR Link
Any Dependency Changes? preset-env has two new deps
License MIT
  • Added compat-data from mdn-browser-compat-data
  • Added a new caller support flag: supportsExportNamespaceFrom, we should also update babel-loader and @rollup/plugin-babel since both two have supported export * as ns.
  • When modules: false (preserve ES modules) is specified, compat-data is used to determine whether export * as ns should be transpiled

This PR includes commits from #11838, I will rebase once it gets merged.

@babel-bot
Copy link
Collaborator

babel-bot commented Jul 17, 2020

Build successful! You can test your changes in the REPL here: https://babeljs.io/repl/build/26144/

@JLHwung JLHwung mentioned this pull request Jul 17, 2020
3 of 3 tasks complete
@billyjanitsch
Copy link

billyjanitsch commented Jul 17, 2020

Thanks @JLHwung! Sorry I didn't get around to working on this.

shouldTransformExportNamespaceFrom: !(
(modules === "auto" && api.caller?.(supportsExportNamespaceFrom)) ||
(modules === false &&
!isRequired("proposal-export-namespace-from", transformTargets, {
compatData,
includes: include.plugins,
excludes: exclude.plugins,
}))
),
Comment on lines 289 to 297

This comment has been minimized.

@nicolo-ribaudo

nicolo-ribaudo Jul 20, 2020 Member

Nit: This is a bit hard to follow. Could we move the ! inside to match the same !/|| pattern used in the lines above?

Suggested change
shouldTransformExportNamespaceFrom: !(
(modules === "auto" && api.caller?.(supportsExportNamespaceFrom)) ||
(modules === false &&
!isRequired("proposal-export-namespace-from", transformTargets, {
compatData,
includes: include.plugins,
excludes: exclude.plugins,
}))
),
shouldTransformExportNamespaceFrom:
(modules !== "auto" || !api.caller?.(supportsExportNamespaceFrom)) &&
(modules !== false || isRequired("proposal-export-namespace-from", transformTargets, {
compatData,
includes: include.plugins,
excludes: exclude.plugins,
}))
),

Or maybe even this doesn't change the readability 🤔😅

This comment has been minimized.

@JLHwung

JLHwung Jul 20, 2020 Author Contributor

Well I initially unwrap ! but I realized that these two modules !== false || something seems pretty mind-jiggling to me. I end up with current patterns. I can wrap these conditions into a new shouldSkipExportNamespaceFrom and it should be more straightforward.

@JLHwung JLHwung force-pushed the JLHwung:add-export-ns-from branch from 3ffcda3 to cfe0b43 Jul 20, 2020
@codesandbox
Copy link

codesandbox bot commented Jul 20, 2020

This pull request is automatically built and testable in CodeSandbox.

To see build info of the built libraries, click here or the icon next to each commit SHA.

Latest deployment of this branch, based on commit cfe0b43:

Sandbox Source
babel-repl-custom-plugin Configuration
babel-plugin-multi-config Configuration
@JLHwung JLHwung changed the base branch from main to feat-7.11.0/stage-4 Jul 21, 2020
@JLHwung
Copy link
Contributor Author

JLHwung commented Jul 21, 2020

I am merging this PR to feat-7.11.0/stage-4 feature branch.

@JLHwung JLHwung merged commit 3784216 into babel:feat-7.11.0/stage-4 Jul 21, 2020
8 of 9 checks passed
8 of 9 checks passed
build
Details
test262-pr Workflow: test262-pr
Details
Gitpod Open an online workspace in Gitpod
Details
Travis CI - Pull Request Build Passed
Details
babel/repl REPL preview is available
Details
build-standalone Workflow: build-standalone
Details
ci/codesandbox Building packages succeeded.
Details
codecov/project 91.85% (target 90.00%)
Details
e2e Workflow: e2e
Details
@JLHwung JLHwung deleted the JLHwung:add-export-ns-from branch Jul 21, 2020
JLHwung added a commit that referenced this pull request Jul 29, 2020
* feat: add compat-data of proposal-export-namespace-from

* feat: add export-namespace-from to preset-env

* chore: update test fixtures

* address review comments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Linked issues

Successfully merging this pull request may close these issues.

5 participants
You can’t perform that action at this time.