11599 Commits

Author SHA1 Message Date
Logan Smyth
007bfb6565
Merge pull request #8010 from loganfsmyth/babel-node-options
Add more of babel-cli's options to babel-node too for consistency.
2018-05-23 09:47:58 -07:00
Logan Smyth
c8faa34848 Only set '.babelrc' option if user explicitly set it. 2018-05-23 09:25:43 -07:00
Logan Smyth
5bcca0123a Add --env-name option to babel-node, like babel-cli's option. 2018-05-23 09:25:05 -07:00
Logan Smyth
1d987fb655 Add --config-file option to babel-node, like babel-cli's option. 2018-05-23 09:23:50 -07:00
Logan Smyth
06e5c46c8d Fix typo in option validation. 2018-05-23 09:23:14 -07:00
Sven SAULEAU
52b800decb Add no-babelrc option in babel-node (#5621)
<!-- 
Before making a PR please make sure to read our contributing guidelines 
https://github.com/babel/babel/blob/master/CONTRIBUTING.md

For any issue references: Add a comma-separated list of a [closing word](https://help.github.com/articles/closing-issues-via-commit-messages/) followed by the ticket number fixed by the PR
-->

| Q                        | A <!--(yes/no) -->
| ------------------------ | ---
| Patch: Bug Fix?          | 
| Major: Breaking Change?  | 
| Minor: New Feature?      | y
| Deprecations?            | 
| Spec Compliancy?         | 
| Tests Added/Pass?        | y/y
| Fixed Tickets            | #5616
| License                  | MIT
| Doc PR                   | <!-- if yes, add `[skip ci]` to your commit message to skip CI builds -->
| Dependency Changes       | 

<!-- Describe your changes below in as much detail as possible -->

Once merged I will make the corresponding documentation changes on the website (in a 7 branch)
2018-05-23 09:19:39 -07:00
Sven SAULEAU
01d969a182
Merge pull request #8009 from babel/xtuc-patch-2
update AST spec - interpreter
2018-05-23 12:57:10 +02:00
Sven SAULEAU
7d99a96f9f
docs: [skip ci] add InterpreterDirective 2018-05-23 09:50:23 +02:00
Sven SAULEAU
ad1de09b5f
docs: [skip ci] update AST spec 2018-05-23 09:42:33 +02:00
Logan Smyth
6b91d6434d Add a try/catch on inline data-uri sourcemaps too, and add debug logging. 2018-05-22 23:38:16 -07:00
Michael Lavina
18796173ab feat(sourcemap): parse external source maps when normalizing (#7980) 2018-05-22 23:29:10 -07:00
Logan Smyth
eb3334a14e
Merge pull request #7955 from loganfsmyth/typescript-filename-required
Verify that files are .ts/.tsx before treating as Typescript files.
2018-05-22 22:41:39 -07:00
Logan Smyth
5e00c96368
Handle Infinity, -Infinity, NaN, and -0 in t.valueToNode(). (#8005)
| Q                        | A <!--(Can use an emoji 👍) -->
| ------------------------ | ---
| Fixed Issues?            | Fixes #8001
| Patch: Bug Fix?          | Y
| Major: Breaking Change?  | Not unless things were relying on a very specific AST structure as output
| Minor: New Feature?      |
| Tests Added + Pass?      | Yes
| Documentation PR         | <!-- If so, add `[skip ci]` to your commit message to skip CI -->
| Any Dependency Changes?  |
| License                  | MIT

The filed bug was for `-0`, but I also realize that `numericLiteral` also shouldn't be getting `-Infinity`/`Infinity` or `NaN` since those just get stringified with the JS-standard stringification logic which means we get a reference to `NaN` or `Infinity` identifiers, which could have been shadowed in a local scope and thus not be the right value. I've avoided that by generating `NaN` as `0/0` and the infinity values as `1/0` and `-1/0`.
2018-05-22 14:37:06 -07:00
Henry Zhu
b4d18f4764
Bigint Support without transform (#8006) 2018-05-22 15:31:34 -04:00
Brian Ng
981bff08e4 Fix some flow issues in @babel/parser flow plugin (#8002) 2018-05-22 10:48:49 -07:00
Nicolò Ribaudo
7d641d2e74
Update babel-types docs (InterpreterDirective) [skip ci] (#8004)
Introduced in #7928
2018-05-22 17:50:15 +02:00
Logan Smyth
f2882d570a Tests for react/ts compat and flow/ts compat. 2018-05-21 21:21:00 -07:00
Logan Smyth
cc5aeb3b50 Allow .ts and .tsx test fixtures. 2018-05-21 20:31:40 -07:00
Logan Smyth
d164f820e6
Merge pull request #7928 from loganfsmyth/shebang-node
Create InterpreterDirective AST node type and use to replace babel/core File's 'shebang' handling
2018-05-21 20:02:12 -07:00
Logan Smyth
43aa61d6be Make the typescript preset require a filename unless the user configured it for general use. 2018-05-21 18:34:50 -07:00
Logan Smyth
ca1c98b255 Allow .overrides and .env inside presets. 2018-05-21 18:23:07 -07:00
Logan Smyth
0963dbddea Rely on Babylon for interpreter directive parsing, instead of babel/core. 2018-05-21 18:19:59 -07:00
Logan Smyth
2058e0686e Add support for an InterpreterDirective AST node. 2018-05-21 18:19:58 -07:00
Logan Smyth
c0013264b7 Add tests for interpreter directive with retainLines and sourcemaps. 2018-05-21 18:08:32 -07:00
Logan Smyth
442ead701c Fix a few out-of-order test results. 2018-05-21 18:08:31 -07:00
Logan Smyth
5fb3696955 Avoid flow errors now that we've renamed Babylon to babel-parser. 2018-05-21 18:06:17 -07:00
Logan Smyth
69cca412eb
Make the filename option, as exposed to the plugins, consistently relative to the working directory (#7956)
| Q                        | A <!--(Can use an emoji 👍) -->
| ------------------------ | ---
| Fixed Issues?            | 
| Patch: Bug Fix?          | Y
| Major: Breaking Change?  | N
| Minor: New Feature?      |
| Tests Added + Pass?      | Yes
| Documentation PR         | <!-- If so, add `[skip ci]` to your commit message to skip CI -->
| Any Dependency Changes?  |
| License                  | MIT

Currently the `opts.filename` value exposed to plugins is just whatever the user passed. While it _could_ be relative to the working directory, if Babel was passed an absolute URL, it'll be absolute.

This PR explicitly ensures the filename is a relative path based on the working directory. This also exposes an officially endorsed API for reading the working directory path.
2018-05-21 17:10:57 -07:00
Mike Nason
3bee37b14d fix typo in error message (#7995) 2018-05-21 12:18:09 -07:00
Miguel Albernaz
bc757c8b75 passes the jsxPragma options from preset-typescript to plugin-transform-typescript (#7990) 2018-05-21 14:33:43 -04:00
Conor Hastings
c558dedd7b fix typo of babel in readme (#7992) [skip ci] 2018-05-21 07:42:13 +02:00
Justin Ridgewell
0879a6d608
Subsume json (#7985)
* Add Subsume JSON transform

https://github.com/tc39/proposal-json-superset is at stage 3.

This allows U+2028 LINE SEPARATOR and U+2029 PARAGRAPH SEPARATOR to appear unescaped inside strings and directives.

* Move to Stage 3

* Break diretive parsing

* Update README

* Handle multi-escape sequences

* Remove babylon files after rename
2018-05-19 15:32:05 -04:00
Henry Zhu
51eef099b3 fixes [skip ci] 2018-05-19 00:12:26 -04:00
Chaitanya Kumar Kamatham
daf0ca8680 Rename "babylon" to "@babel/parser" (#7937) 🎉 2018-05-19 00:03:05 -04:00
Justin Ridgewell
0200a3e510
Build InterfaceTypeAnnotation generated type code (#7982) 2018-05-18 14:41:19 -04:00
Justin Ridgewell
27c39c512d
Class private properties (#7842)
* Update member-expression-to-functions

1. Babel using British spellings, so `memoise`
2. Provide a helper `AssignmentMemoiser` class, which will assign the memo'd value with the `n`th access.

* Private properties!

* Fixes

* Tests

* Update helper name

* Fix privates that reference other privates

* Don't extend a builtin

* Rebase
2018-05-18 14:03:23 -04:00
Ben Newman
70eb206c03 TypeScript: Fix TSInferType .typeParameter type. (#7967)
Follow-up to https://github.com/babel/babel/pull/7404

There is no TypeParameter type in the Babylon TypeScript AST hierarchy.
Flow does have a TypeParameter type, but it should not be confused with
the TypeScript TSTypeParameter, since Flow !== TypeScript, and the types
have totally different fields. Instead, the .typeParameter.type of a
Babylon-parsed TSInferType node should be TSTypeParameter.

It would probably be fine to leave the declared type of the TSInferType
.typeParameter field as TSType instead of TSTypeParameter, but the more
specific TSTypeParameter type should be safe/correct, since the TypeScript
parseInferType function always uses SyntaxKind.TypeParameter:
66d6e5e6e0/src/compiler/parser.ts (L3006)

I noticed this typo because it has been causing ast-types test failures
lately, e.g. https://travis-ci.org/benjamn/ast-types/jobs/369634972
2018-05-18 10:15:48 -05:00
Nicolò Ribaudo
229179b8aa Update babel-types (flow internal slots) (#7977) 2018-05-18 08:47:31 -05:00
Sam Goldman
6baa36cdc5 Support Flow's inline interface syntax (#7973)
* Support Flow's inline interface syntax

* Fix babel-generator
2018-05-18 08:11:27 -05:00
Sam Goldman
a40f54f847 Add support for explicit type arguments in new and call expressions (#7934)
* Add all option to babel-plugin-syntax-flow

The Flow parser has some conditional logic based on whether types should
be parsed or not, which is based on either (a) the @flow pragma in the
docblock of the file of (b) the `all` configuration, provided via
command line or .flowconfig.

This commit adds the ability to provide the `all` configuration to
Babel as well, via the syntax-flow plugin. This should be set to `true`
if the project uses all=true.

* Parse @flow pragma

The Flow parser has some conditional logic based on whether types should
be parsed or not, which is based on either (a) the @flow pragma in the
docblock of the file of (b) the `all` configuration, provided via
command line or .flowconfig.

This commit parses the @flow (or @noflow) pragma from the first comment
in the source file. Directives are allowed to appear before the comment.

* WIP: add tests for explicit type arguments

This commit includes tests which have unexpected output, but will change
to the expected output as later commits add parsing support for various
features.

* Parse type arguments in new expressions

* Parse type arguments in call expressions

* Parse optional call expressions with explicit type args

* Add explicit type arguments to babel-types

Flow calls these typeArguments instead of typeParameters, which clearly
separates formal/actual parameters, and mirrors the existing arguments
key.

The existing definitions to support TypeScript also included Flow's
TypeParameterInstantiation node type, which I've moved to the the new
field.

* Add support for explicit type arguments to babel-generator

* Add test for explicit type args to transform-flow-strip-types plugin

* Oops. Forgot to regenerate the babel-types README.

* Fix Flow parser shouldParseTypes() function

I was looking at `options.all`, but the correct property ws
`options.flowAll`. Oops!

* Remove typeapp_call from whitelist of expected failures

Now that Babylon parses this syntax extension, we can remove the
typeapp_call tests from the list of expected differences.

Note that I am using the `flowAll` option, mirroring the behavior of the
Flow tests, which assume types without requiring the `@flow` pragma.

* Use Babylon plugin options instead of parser options

* Parse optional call expressions type arguments unambiguously
2018-05-18 08:05:16 -05:00
Nicolò Ribaudo
6226c52f43
Add "legacy" prefix to legacy decorators tests (#7975) 2018-05-18 14:46:07 +02:00
Lars Willighagen
25153359f7 helper-plugin-utils: Move README [skip ci] (#7972)
Move README from src to package root, as in other packages.

Closes #7971
2018-05-18 10:00:25 +02:00
Nicolò Ribaudo
2351a638b5
Fix bugs in the _wrapNativeSuper helper (#7533)
* Remove second wrapper from _wrapNativeSuper

* Fix tests on node 4

I DON'T KNOW WHY IT WORKS.

* Update fixtures

* Use Reflect.construct

* Parens

* Fix things

* Fix things

* Undo changes

* Fix with sham

* Typo
2018-05-18 00:04:12 +02:00
Rubén Norte
bc6f0f989d Re-add support for local Flow bindings (TypeAlias, OpaqueTypeAlias and Interface) (#7900) 2018-05-17 10:54:14 -07:00
Sam Goldman
af7ab71486 Allow flow internal slot properties to be optional (#7959)
See 23d1b1c5f2
2018-05-17 19:01:03 +02:00
Logan Smyth
ac13c302f7
Merge pull request #7929 from loganfsmyth/cli-refactoring
Refactor babel-cli to use async functions for async handling, and centralize option loading
2018-05-16 20:58:46 -07:00
Sam Goldman
b396cdcbe5 Internal slot properties (#7947)
* Support internalSlots to babel-types and babel-generator

* Parsing support for internal slot properties

* Print internal slots in babel-generator

* Add whitespace before first internal slot property
2018-05-16 22:48:12 -05:00
Michal Artazov
8dcfabd0d7 update core-js to 2.5.6 (#7950) 2018-05-16 10:08:19 -07:00
Nicolò Ribaudo
e45d5c3b65 Add an option to Babylon to have decorators before export (#7869)
* Add support for plugin options in Babylon

They work similarly to how they work in Babel. e.g.
  babylon.parse({
    options: [
      "plugin1",
      ["plugin2", { option: true }]
    ]
  });

The inernal api to get an option is
  this.getPluginOption("pluginName", "option")
If the plugin isn't defined, it returns undefined.

* Add Babylon option decorators.secoratorsBeforeExport

* Nit
2018-05-15 11:39:53 -05:00
Logan Smyth
8ff675ad69 Refactor CLI to use promises/async fns. 2018-05-14 23:07:50 -07:00
Logan Smyth
a955efa3e3
Ensure that calling register fully resets the state. (#7930) 2018-05-14 23:04:56 -07:00