-
Notifications
You must be signed in to change notification settings - Fork 571
Support es modules #4232
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
Merged
JordanMartinez
merged 69 commits into
purescript:master
from
working-group-purescript-es:es-modules+purity-annotations
Feb 27, 2022
Merged
Support es modules #4232
Changes from all commits
Commits
Show all changes
69 commits
Select commit
Hold shift + click to select a range
6c481c8
Add ES imports/exports to CoreImp AST
kl0tl 52a692b
Print ES imports/exports
kl0tl cd40596
Codegen ES imports for PureScript modules
kl0tl 607dd3d
Codegen ES imports for foreign modules
kl0tl 19878e3
Codegen ES exports
kl0tl 4889861
Extract both CJS and ES exports from foreign modules
kl0tl c03399f
Remove the redundant "use strict;" pragma from modules header
kl0tl 71c2de3
Don’t emit empty statements for empty exports lists
kl0tl 7d4ef3d
Bundle ES modules
kl0tl 7f0c07e
Load ES modules with `esm` in the Node.js REPL and tests
kl0tl e006953
Escape primes in modules accessors
kl0tl 243ec5e
Forbid unescaped primes in foreign modules exports
kl0tl ddbb2ad
Run tests against patched dependencies
kl0tl e5b1798
Rewrite ES modules in the browser REPL client
kl0tl 47cdee9
Merge branch 'master' into es-modules
kl0tl c5ffab6
Revert "Load ES modules with `esm` in the Node.js REPL and tests"
kl0tl 4713b2a
Allow Node.js to load .js files in the output directory as ES modules
kl0tl 7784dd1
Import CommonJS foreign modules through an ES module wrapper
kl0tl 1587749
Don't let tests nor the REPL compile into a node_modules directory
kl0tl ba9f084
Bundle re-exports
kl0tl 65dab5d
Load bundles as CommonJS modules in tests
kl0tl 830bbe2
Update Node.js version on CI
kl0tl 4976eee
Disallow CommonJS exports named `default`
kl0tl f73c2bf
Disallow CommonJS exports and imports in ES foreign modules
kl0tl c56d3f5
Deprecate CommonJS foreign modules
kl0tl 94af221
Convert CommonJS foreign modules in tests to ES modules
kl0tl 15ebf0d
Don't optimize away dependencies of named ES exports of declarations
kl0tl 8f19b7e
fixup! Import CommonJS foreign modules through an ES module wrapper
kl0tl 7727c98
fixup! Don't optimize away dependencies of named ES exports of declar…
kl0tl bd45602
Revert "Disallow CommonJS exports named `default`"
kl0tl ca94c4b
Add tests for foreign CommonJS exports named default
kl0tl ec4dce5
Extend support to Node.js v12.0.0 with --experimental-modules
kl0tl 0d6f928
Filter out Node.js experimental ES modules loader warning
kl0tl 8e1caf8
Update bundler error messages
kl0tl 7ef3aad
Merge branch 'master' into next
kl0tl d5437e0
Fix HLint warnings
kl0tl 721807c
Merge remote-tracking branch 'upstream/master' into es-modules
kl0tl d3b6633
Add purity annotations to function applications and constructor insta…
kl0tl 87e72e0
Merge remote-tracking branch 'upstream/master' into es-modules+purity…
i-am-the-slime c630052
Surround purity annotations in parens
i-am-the-slime 8a0779c
Mention es modules in version
i-am-the-slime 593230b
Bump version to 0.15.0
i-am-the-slime 8a7b220
Add purity annotations to top-level applications only.
natefaubion a1258f2
Follow top-level literals as well
natefaubion f3b9d34
Annotate all top-level-reachable applications.
natefaubion b72f7f8
Traverse under lhs functions and operators
natefaubion d67aa9e
Use # for annotation.
natefaubion 19f4bdc
Add comments, remove potentially aggressive cases.
natefaubion ce9a906
Simplify to uniform top-level IIFEs.
natefaubion 9d997ea
Fix tests
sigma-andex 7a458ff
Add myself to contributors
sigma-andex 67c536a
Merge pull request #10 from working-group-purescript-es/add-to-contri…
thomashoneyman 3a3abde
Fix experimental-modules flag required version (#11)
sigma-andex e535003
Add i-am-the-slime to contributors
i-am-the-slime d57898d
Fix pr comments (#12)
sigma-andex 8f79b9d
Merge branch 'master' into es-modules+purity-annotations
sigma-andex efa6f87
Add resolutions to fix dep conflicts
JordanMartinez c35d12b
Add changelog.d entry for es modules (#14)
sigma-andex ed3f494
Update prefix to match script's expected one
JordanMartinez 970a8e6
Drop unneeded whitespace
JordanMartinez 16430f3
Update src/Language/PureScript/Errors.hs
sigma-andex f861e5e
Fix broken tests after spelling correction commit
sigma-andex fba2a49
Remove temporary entries from changelog
sigma-andex 993ade0
Remove version update
sigma-andex 69df129
Stop using es modules branch for lists dependency
JordanMartinez deec912
Merge branch 'master' into es-modules+purity-annotations
JordanMartinez a1a1eff
Refactor Pure -> Comment in CoreImp
rhendric 9f29b4d
Refactor CoreImp modules
rhendric 038108e
Be less liberal with IIFEs
rhendric File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
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
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,26 @@ | ||
| * Switch from Common JS to ES modules | ||
|
|
||
| Previously, Purescript used Common JS for FFI declarations. | ||
|
|
||
| Before, FFI was declared like this... | ||
|
|
||
| ```javascript | ||
| const mymodule = require('mymodule') | ||
|
|
||
| exports.myvar = mymodule.myvar | ||
| ``` | ||
|
|
||
| ...and will be changed to this... | ||
|
|
||
| ```javascript | ||
| import * as M from 'mymodule'; | ||
| export const myvar = M.myvar | ||
| ``` | ||
| ...or using the short version... | ||
|
|
||
| ```javascript | ||
| export { myvar } from 'mymodule'; | ||
| ``` | ||
|
|
||
| * FFI is annotated with `/* #__PURE__ */` so that bundlers can perform DCE | ||
| * The current LTS Node.js version `12` is now the required minimum version |
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
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
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
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
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.
Uh oh!
There was an error while loading. Please reload this page.
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.
Should these regexes account for extra spaces? For example
The
requireregex on which these are likely based did not need to account for extra whitespace issues.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.
afaik this is in the repl in browser feature, which hasn't been updated yet.
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.
Ah, I see. This code only runs when
purs repl --port somePortis called. I've always just usedpurs repl, which is always using the Node backend.But shouldn't this be fixed here? Or does that mess up tests and hence why it hasn't yet?
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's not clear to me what the resolution was here. Do we need to note this in the release? Will it be updated or will it be removed? Will that happen in a subsequent PR?
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.
Wasn't the idea to remove the browser repl in a subsequent PR?
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.
I'm fine with removing it, but it wasn't clear to me there was any consensus here with the core team. Did I miss that?
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.
I've missed a few meetings, but I don't think there has been consensus yet as I don't think this has come up. I'm up for removing it though because I've never used the browser version. If I want a REPL-like experience, I usually just use Try PureScript because there's a small bug in one part of my code and starting a REPL just to debug that one function isn't worth it to me.