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

Support import and export of ES2015 modules #4300

Merged
merged 92 commits into from
Sep 14, 2016
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
92 commits
Select commit Hold shift + click to select a range
c2b55da
Start implementing support for `import` and `export`: start with a fa…
GeoffreyBooth Jul 25, 2016
141ec77
Remove `import`, `export` and `default` from reserved list
GeoffreyBooth Jul 25, 2016
2a0f178
Follow the example of `Class` and create a new expression for `Import`
GeoffreyBooth Jul 25, 2016
21de343
Add support for simple import *statement* to identifier
Jul 27, 2016
118c11c
Add IdentifierList and NamedImport to the grammar as well as IMPORT_F…
Jul 28, 2016
d2e6481
Remove accidently committed console.log debug output
Jul 28, 2016
d86540a
Remove IMPORT regex that has never been used
Jul 28, 2016
de78f48
NamedImports work now and can be mixed with Identifiers as well
Jul 28, 2016
41e0e77
Define CoffeeScript import/export syntax, lifted almost verbatim from…
GeoffreyBooth Aug 1, 2016
a512175
Rename Import constructor arguments to match grammar
GeoffreyBooth Aug 1, 2016
d0ef270
Make lexer additions more idiomatic; add beginnings of support for `e…
GeoffreyBooth Aug 1, 2016
00b7d7c
Reorder import grammar for clarity; WIP getting asterisk recognized a…
GeoffreyBooth Aug 1, 2016
b70fb59
Reset seenImport and seenExport for each line
GeoffreyBooth Aug 2, 2016
57fd515
Parse asterisk within import statement
GeoffreyBooth Aug 2, 2016
e72017c
Let’s not assume that the runtime supports String::includes
GeoffreyBooth Aug 2, 2016
b92c843
Comma-delimited import members, WIP
GeoffreyBooth Aug 2, 2016
05aa40b
Simplify grammar, treating everything as an ImportList that can be wr…
GeoffreyBooth Aug 3, 2016
e5453c2
Update tests to add check for scope, that no extra `var` lines are ge…
GeoffreyBooth Aug 7, 2016
77f445f
Per the spec, the default import must be declared first
GeoffreyBooth Aug 7, 2016
752669b
Standardize naming based on precedent
GeoffreyBooth Aug 9, 2016
661ad4a
Handle the “export import” cases, where we’re importing and exporting…
GeoffreyBooth Aug 9, 2016
2df3e9d
Rename ImportIdentifier to ModuleIdentifier, expand it to handle expo…
GeoffreyBooth Aug 9, 2016
9f771e2
Export: handle common cases: `export { foo, bar }`, `export { foo as …
GeoffreyBooth Aug 9, 2016
bc46e30
Handle exporting imported modules; i.e. `export ... from 'lib'`
GeoffreyBooth Aug 9, 2016
3d4fd5f
Comment out broken tests (will we support these syntaxes?)
GeoffreyBooth Aug 9, 2016
218e975
Consolidate ImportList and ExportList into ModuleList
GeoffreyBooth Aug 9, 2016
afae27b
Use `new Literal` to simplify ModuleIdentifier
GeoffreyBooth Aug 9, 2016
570191f
Consolidate Import and Export classes together
GeoffreyBooth Aug 9, 2016
0bb6dcd
Add another failing multiline test (commented-out)
GeoffreyBooth Aug 9, 2016
858c7b5
Force `bare: true` option if a file contains an `import` or `export` …
GeoffreyBooth Aug 11, 2016
d0fef4c
Declare two troublesome export syntaxes as explicitly unsupported, an…
GeoffreyBooth Aug 11, 2016
435971a
Reorder Module arguments for simplicity
GeoffreyBooth Aug 11, 2016
4c9d595
Support export default blocks (like exporting a default function)
GeoffreyBooth Aug 11, 2016
11bbd34
Partially fix multi-line support of import statements
Aug 11, 2016
027b5c2
Add back multi-line tests with preserving whitespace as comments for …
Aug 11, 2016
10a6a4c
Appeasing the code-golfing peanut gallery
GeoffreyBooth Aug 12, 2016
8c08ae4
Always output “wrapped” (destructured) import or export member lists …
GeoffreyBooth Aug 12, 2016
43b0248
No need for a distinct `IMPORT_FROM`, we can recycle the `FROM` token…
GeoffreyBooth Aug 12, 2016
e95e232
`IMPORT_AS` and `EXPORT_AS` can be collapsed together as just `AS`; `…
GeoffreyBooth Aug 12, 2016
b211a51
Test `export default class` (commented out for now, as the generated …
GeoffreyBooth Aug 12, 2016
6b27e23
`from` doesn’t need to be a reserved word; when not part of an import…
GeoffreyBooth Aug 12, 2016
7ed7075
Ensure that the names of modules we’re importing from are plain strin…
GeoffreyBooth Aug 13, 2016
b7bf15d
Limited test for `export default class`
GeoffreyBooth Aug 13, 2016
a7db3bf
Export statements (that aren’t also import statements) that define va…
GeoffreyBooth Aug 13, 2016
8b0672b
Change test for `from` assignability to be more coffee-like, not comp…
GeoffreyBooth Aug 13, 2016
c0b974d
Test for exporting primitives as default: string, number, plain object
GeoffreyBooth Aug 13, 2016
29467a9
Export non-default class
GeoffreyBooth Aug 13, 2016
7a3113e
Support exporting non-default identifiers and classes; limit the defa…
GeoffreyBooth Aug 14, 2016
3a71484
Get rid of SimpleString in favor of checking for an interpolated stri…
GeoffreyBooth Aug 14, 2016
a486731
Support exporting non-default assignments, e.g. `export foo = 'bar'`
GeoffreyBooth Aug 14, 2016
2589a35
Simplify things with subclasses of Module class
GeoffreyBooth Aug 15, 2016
1242669
For `EXPORT Identifier = Expression` grammar, insert the `var` as par…
GeoffreyBooth Aug 15, 2016
e1ac869
Edge case failing tests
GeoffreyBooth Aug 15, 2016
452f073
Handle `as` as an identifier within an `import` or `export` statement…
GeoffreyBooth Aug 15, 2016
1e0714e
Define 'FROM' token only when in an import or export statement and `f…
GeoffreyBooth Aug 15, 2016
cfc18c4
New `import` or `export` context to `Assign`, tracked to prevent `imp…
GeoffreyBooth Aug 17, 2016
6df73cd
Safer check
GeoffreyBooth Aug 17, 2016
c3893d7
Instead of a new `Assign` context of `import` or `export`, add a new …
GeoffreyBooth Aug 17, 2016
be49dc0
Add new `export` syntaxes to big comment explaining module syntaxes
GeoffreyBooth Aug 17, 2016
3eb4533
Throw an error if an import or export statement isn’t at the top-leve…
GeoffreyBooth Aug 19, 2016
857b603
Don’t rewrite `*` as `IMPORT_ALL` within an export expression, with test
GeoffreyBooth Aug 24, 2016
eb52daf
Pull request attempt #1! Here goes nothing . . .
GeoffreyBooth Aug 31, 2016
8d8e818
Merge remote-tracking branch 'upstream/master' into import-export
GeoffreyBooth Aug 31, 2016
c1cdccf
Improve comments
GeoffreyBooth Sep 1, 2016
e531483
Test for optional commas
GeoffreyBooth Sep 1, 2016
f32f78f
Fix: `export class foo` should produce `export var foo = ...`, not `v…
GeoffreyBooth Sep 1, 2016
d3f64b9
Test multiline import with comments
GeoffreyBooth Sep 1, 2016
d1246ff
Better error messages for interpolated module names or anonymous classes
GeoffreyBooth Sep 1, 2016
fbdc0c3
Use lexer’s `@tag` and `@value` to be more idiomatic
GeoffreyBooth Sep 1, 2016
1bf414e
Change backticked import statement test to be a more typical example
GeoffreyBooth Sep 1, 2016
2d60c31
Add test for comma-less multiline module clause; drop support for opt…
GeoffreyBooth Sep 1, 2016
a697423
Allow optional commas in destructured imports; restore tests
GeoffreyBooth Sep 1, 2016
23817b5
Update definition comment
GeoffreyBooth Sep 1, 2016
5390423
Allow export empty object; disallow import empty object
GeoffreyBooth Sep 1, 2016
bfa06f8
Throw an error for `import a as b from 'c'`
GeoffreyBooth Sep 2, 2016
befd628
Disallow unwrapped imports that don’t follow the very constrained ES2…
GeoffreyBooth Sep 2, 2016
5455fb3
Disallow `export *` (as opposed to `export * from 'lib'`)
GeoffreyBooth Sep 2, 2016
b7e60c4
Cleanup
GeoffreyBooth Sep 2, 2016
3792c6d
Refactor so that disallowed syntaxes never make it past the grammar; …
GeoffreyBooth Sep 4, 2016
f52dc71
Export multiline assignment expression
GeoffreyBooth Sep 5, 2016
78a6ad5
Members cannot be imported multiple times
GeoffreyBooth Sep 5, 2016
52da316
When importing, check scope to disallow duplicate imports
GeoffreyBooth Sep 6, 2016
74fe5a6
Rename some nodes and properties to follow Babel’s AST names
GeoffreyBooth Sep 8, 2016
2de4650
Throw an error on trying to reassign an imported variable
GeoffreyBooth Sep 8, 2016
6fce45d
Throw an error on trying to assign a read-only imported variable as p…
GeoffreyBooth Sep 8, 2016
52107f9
Style cleanup
GeoffreyBooth Sep 8, 2016
8469313
Style cleanup
GeoffreyBooth Sep 8, 2016
71a400c
Collapse 'already imported' and 'duplicate declaration' checks into o…
GeoffreyBooth Sep 8, 2016
0557586
Allow importing an empty object; better nodes for imported and export…
GeoffreyBooth Sep 9, 2016
c99950a
Better error message for duplicate declaration (or a variable declara…
GeoffreyBooth Sep 9, 2016
bf1caa2
Pull comma literal out of the grammar
GeoffreyBooth Sep 9, 2016
4b45b09
Add ImportClause node
GeoffreyBooth Sep 14, 2016
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 13 additions & 4 deletions lib/coffee-script/coffee-script.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

100 changes: 98 additions & 2 deletions lib/coffee-script/grammar.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

35 changes: 27 additions & 8 deletions lib/coffee-script/lexer.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading