diff --git a/packages/babel-core/test/fixtures/transformation/misc/shebang/input.js b/packages/babel-core/test/fixtures/transformation/misc/interpreter-directive/input.js similarity index 100% rename from packages/babel-core/test/fixtures/transformation/misc/shebang/input.js rename to packages/babel-core/test/fixtures/transformation/misc/interpreter-directive/input.js diff --git a/packages/babel-core/test/fixtures/transformation/misc/shebang/output.js b/packages/babel-core/test/fixtures/transformation/misc/interpreter-directive/output.js similarity index 100% rename from packages/babel-core/test/fixtures/transformation/misc/shebang/output.js rename to packages/babel-core/test/fixtures/transformation/misc/interpreter-directive/output.js diff --git a/packages/babel-core/test/fixtures/transformation/misc/retain-lines-interpreter-directive/input.js b/packages/babel-core/test/fixtures/transformation/misc/retain-lines-interpreter-directive/input.js new file mode 100644 index 0000000000..a65ccc171e --- /dev/null +++ b/packages/babel-core/test/fixtures/transformation/misc/retain-lines-interpreter-directive/input.js @@ -0,0 +1,2 @@ +#!env node +var someFirstLine; diff --git a/packages/babel-core/test/fixtures/transformation/misc/retain-lines-interpreter-directive/options.json b/packages/babel-core/test/fixtures/transformation/misc/retain-lines-interpreter-directive/options.json new file mode 100644 index 0000000000..1207eeafcf --- /dev/null +++ b/packages/babel-core/test/fixtures/transformation/misc/retain-lines-interpreter-directive/options.json @@ -0,0 +1,4 @@ +{ + "plugins": ["transform-strict-mode"], + "retainLines": true +} diff --git a/packages/babel-core/test/fixtures/transformation/misc/retain-lines-interpreter-directive/output.js b/packages/babel-core/test/fixtures/transformation/misc/retain-lines-interpreter-directive/output.js new file mode 100644 index 0000000000..d80bd4fad6 --- /dev/null +++ b/packages/babel-core/test/fixtures/transformation/misc/retain-lines-interpreter-directive/output.js @@ -0,0 +1,3 @@ +#!env node +"use strict"; +var someFirstLine; diff --git a/packages/babel-core/test/fixtures/transformation/source-maps/interpreter-directive-prefix/input.js b/packages/babel-core/test/fixtures/transformation/source-maps/interpreter-directive-prefix/input.js new file mode 100644 index 0000000000..2ca38aa7b8 --- /dev/null +++ b/packages/babel-core/test/fixtures/transformation/source-maps/interpreter-directive-prefix/input.js @@ -0,0 +1,3 @@ +#!env node + +console.log("Hello, world!"); diff --git a/packages/babel-core/test/fixtures/transformation/source-maps/interpreter-directive-prefix/options.json b/packages/babel-core/test/fixtures/transformation/source-maps/interpreter-directive-prefix/options.json new file mode 100644 index 0000000000..a7aed2bcf8 --- /dev/null +++ b/packages/babel-core/test/fixtures/transformation/source-maps/interpreter-directive-prefix/options.json @@ -0,0 +1,3 @@ +{ + "sourceMap": true +} diff --git a/packages/babel-core/test/fixtures/transformation/source-maps/interpreter-directive-prefix/output.js b/packages/babel-core/test/fixtures/transformation/source-maps/interpreter-directive-prefix/output.js new file mode 100644 index 0000000000..cdf7ee7cc5 --- /dev/null +++ b/packages/babel-core/test/fixtures/transformation/source-maps/interpreter-directive-prefix/output.js @@ -0,0 +1,2 @@ +#!env node +console.log("Hello, world!"); diff --git a/packages/babel-core/test/fixtures/transformation/source-maps/interpreter-directive-prefix/source-map.json b/packages/babel-core/test/fixtures/transformation/source-maps/interpreter-directive-prefix/source-map.json new file mode 100644 index 0000000000..85e289c689 --- /dev/null +++ b/packages/babel-core/test/fixtures/transformation/source-maps/interpreter-directive-prefix/source-map.json @@ -0,0 +1,14 @@ +{ + "mappings": "AAEAA,QAAQC,GAAR,CAAY,eAAZ", + "names": [ + "console", + "log" + ], + "sources": [ + "source-maps/interpreter-directive-prefix/input.js" + ], + "sourcesContent": [ + "\n\nconsole.log(\"Hello, world!\");" + ], + "version": 3 +} diff --git a/packages/babylon/test/fixtures/comments/basic/interpreter-directive-import/input.js b/packages/babylon/test/fixtures/comments/basic/interpreter-directive-import/input.js new file mode 100755 index 0000000000..450358ed06 --- /dev/null +++ b/packages/babylon/test/fixtures/comments/basic/interpreter-directive-import/input.js @@ -0,0 +1,3 @@ +#!/usr/bin/env babel-node + +import {spawn} from 'foobar'; diff --git a/packages/babylon/test/fixtures/comments/basic/interpreter-directive-import/options.json b/packages/babylon/test/fixtures/comments/basic/interpreter-directive-import/options.json new file mode 100644 index 0000000000..2104ca4328 --- /dev/null +++ b/packages/babylon/test/fixtures/comments/basic/interpreter-directive-import/options.json @@ -0,0 +1,3 @@ +{ + "sourceType": "module" +} diff --git a/packages/babylon/test/fixtures/comments/basic/interpreter-directive-import/output.json b/packages/babylon/test/fixtures/comments/basic/interpreter-directive-import/output.json new file mode 100644 index 0000000000..b22a2f74d0 --- /dev/null +++ b/packages/babylon/test/fixtures/comments/basic/interpreter-directive-import/output.json @@ -0,0 +1,156 @@ +{ + "type": "File", + "start": 0, + "end": 56, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 3, + "column": 29 + } + }, + "program": { + "type": "Program", + "start": 0, + "end": 56, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 3, + "column": 29 + } + }, + "sourceType": "module", + "body": [ + { + "type": "ImportDeclaration", + "start": 27, + "end": 56, + "loc": { + "start": { + "line": 3, + "column": 0 + }, + "end": { + "line": 3, + "column": 29 + } + }, + "specifiers": [ + { + "type": "ImportSpecifier", + "start": 35, + "end": 40, + "loc": { + "start": { + "line": 3, + "column": 8 + }, + "end": { + "line": 3, + "column": 13 + } + }, + "imported": { + "type": "Identifier", + "start": 35, + "end": 40, + "loc": { + "start": { + "line": 3, + "column": 8 + }, + "end": { + "line": 3, + "column": 13 + }, + "identifierName": "spawn" + }, + "name": "spawn" + }, + "local": { + "type": "Identifier", + "start": 35, + "end": 40, + "loc": { + "start": { + "line": 3, + "column": 8 + }, + "end": { + "line": 3, + "column": 13 + }, + "identifierName": "spawn" + }, + "name": "spawn" + } + } + ], + "source": { + "type": "StringLiteral", + "start": 47, + "end": 55, + "loc": { + "start": { + "line": 3, + "column": 20 + }, + "end": { + "line": 3, + "column": 28 + } + }, + "extra": { + "rawValue": "foobar", + "raw": "'foobar'" + }, + "value": "foobar" + }, + "leadingComments": [ + { + "type": "CommentLine", + "value": "/usr/bin/env babel-node", + "start": 0, + "end": 25, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 25 + } + } + } + ] + } + ], + "directives": [] + }, + "comments": [ + { + "type": "CommentLine", + "value": "/usr/bin/env babel-node", + "start": 0, + "end": 25, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 25 + } + } + } + ] +} \ No newline at end of file diff --git a/packages/babylon/test/fixtures/comments/basic/interpreter-directive-object/input.js b/packages/babylon/test/fixtures/comments/basic/interpreter-directive-object/input.js new file mode 100755 index 0000000000..a61adc7c27 --- /dev/null +++ b/packages/babylon/test/fixtures/comments/basic/interpreter-directive-object/input.js @@ -0,0 +1,3 @@ +#!/usr/bin/env babel-node + +var { spawn } = x; diff --git a/packages/babylon/test/fixtures/comments/basic/interpreter-directive-object/output.json b/packages/babylon/test/fixtures/comments/basic/interpreter-directive-object/output.json new file mode 100644 index 0000000000..771533fc5f --- /dev/null +++ b/packages/babylon/test/fixtures/comments/basic/interpreter-directive-object/output.json @@ -0,0 +1,192 @@ +{ + "type": "File", + "start": 0, + "end": 45, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 3, + "column": 18 + } + }, + "program": { + "type": "Program", + "start": 0, + "end": 45, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 3, + "column": 18 + } + }, + "sourceType": "script", + "body": [ + { + "type": "VariableDeclaration", + "start": 27, + "end": 45, + "loc": { + "start": { + "line": 3, + "column": 0 + }, + "end": { + "line": 3, + "column": 18 + } + }, + "declarations": [ + { + "type": "VariableDeclarator", + "start": 31, + "end": 44, + "loc": { + "start": { + "line": 3, + "column": 4 + }, + "end": { + "line": 3, + "column": 17 + } + }, + "id": { + "type": "ObjectPattern", + "start": 31, + "end": 40, + "loc": { + "start": { + "line": 3, + "column": 4 + }, + "end": { + "line": 3, + "column": 13 + } + }, + "properties": [ + { + "type": "ObjectProperty", + "start": 33, + "end": 38, + "loc": { + "start": { + "line": 3, + "column": 6 + }, + "end": { + "line": 3, + "column": 11 + } + }, + "method": false, + "key": { + "type": "Identifier", + "start": 33, + "end": 38, + "loc": { + "start": { + "line": 3, + "column": 6 + }, + "end": { + "line": 3, + "column": 11 + }, + "identifierName": "spawn" + }, + "name": "spawn" + }, + "computed": false, + "shorthand": true, + "value": { + "type": "Identifier", + "start": 33, + "end": 38, + "loc": { + "start": { + "line": 3, + "column": 6 + }, + "end": { + "line": 3, + "column": 11 + }, + "identifierName": "spawn" + }, + "name": "spawn" + }, + "extra": { + "shorthand": true + } + } + ] + }, + "init": { + "type": "Identifier", + "start": 43, + "end": 44, + "loc": { + "start": { + "line": 3, + "column": 16 + }, + "end": { + "line": 3, + "column": 17 + }, + "identifierName": "x" + }, + "name": "x" + } + } + ], + "kind": "var", + "leadingComments": [ + { + "type": "CommentLine", + "value": "/usr/bin/env babel-node", + "start": 0, + "end": 25, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 25 + } + } + } + ] + } + ], + "directives": [] + }, + "comments": [ + { + "type": "CommentLine", + "value": "/usr/bin/env babel-node", + "start": 0, + "end": 25, + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 25 + } + } + } + ] +} \ No newline at end of file