* Fix default sourceFileName.
This deals with a problem mentioned in [babel/babelify#255][0]. I'm not
super sure about the implications, but it seems this may have been a
regression from Babel 6.
In babel@6, the default `sourceFileName` was the basename of the input
file:
```js
require('babel-core').transform('var a = 10', {
filename: __filename,
sourceMaps: true
}).map
// { version: 3,
// sources: [ 'index.js' ],
// names: [ 'a' ],
// mappings: 'AAAA,IAAIA,IAAI,EAAR',
// file: 'index.js',
// sourcesContent: [ 'var a = 10' ] } }
```
Currently however, the full file path is used:
```js
require('@babel/core').transformSync('var a = 10', {
filename: __filename,
sourceMaps: true
}).map
// { version: 3,
// sources: [ '/home/goto-bus-stop/Code/babel/repro-babelify-255/index.js' ],
// names: [ 'a' ],
// mappings: 'AAAA,IAAIA,IAAI,EAAR',
// file: '/home/goto-bus-stop/Code/babel/repro-babelify-255/index.js',
// sourcesContent: [ 'var a = 10' ] } }
```
This patch adds the `path.basename()` call that [Babel 6 used][1] to
@babel/core's default options, so it's the same as back then.
```js
require('../babel/packages/babel-core').transform('var a = 10', {
filename: __filename,
sourceMaps: true
}).map
// { version: 3,
// sources: [ 'index.js' ],
// names: [ 'a' ],
// mappings: 'AAAA,IAAIA,IAAI,EAAR',
// sourcesContent: [ 'var a = 10' ] }
```
This is the desired behaviour for browserify at least, as it expects
relative paths in the source maps and rebases them to a root directory
when generating the final source map.
[0]: https://github.com/babel/babelify/pull/255
[1]: 6689d2d23c/packages/babel-core/src/transformation/file/index.js (L163-L172)
* Use cwd-relative path for sourceFileName.
* Revert sourceMap `file` property change.
* fixup! Revert sourceMap `file` property change.
* Fix whitespace change from merge conflict
* Revert to using basename in source map outputs.
* Handling babylon parsing errors in a better way
* Better error messages + Helpful URLs
* Replaced message from babylon completely
* Add importMeta plugin to the map
* Remove whitespace generation and rely on default printing
Changes to printing:
* Add newline after last empty SwitchCase
* Add newlines around block comments if they are non-flow comments or contain newlines
* Fix a few more fixtures
This encapsulates the logic for turning an acceptable preset name into
the absolute path for that preset. It can be used to preprocess a
presets list to map each preset to its absolute path, which is necessary
if `babel.transform` is going to be executed on a file outside the
directory subtree where the presets are installed.
This adds a getPossiblePresetNames helper encapsulating the logic for
what preset names we should try to resolve, and the resolvePreset method
just calls this helper and actually resolves them.
This encapsulates the logic for turning an acceptable plugin name into
the absolute path for that plugin. It can be used to preprocess a
plugins list to map each plugin to its absolute path, which is necessary
if `babel.transform` is going to be executed on a file outside the
directory subtree where the plugins are installed.
This adds a getPossiblePluginNames helper encapsulating the logic for
what plugin names we should try to resolve, and the resolvePlugin method
just calls this helper and actually resolves them.
* babel-core: add options for different parser/generator
* test for experiemental plugins, other babylon options
* fix passing options into parser
* Fix when no code is provided
* fixup tests
* fix tests again
* use filename and fallback to cwd
This reverts commit 033681af8941d9678961f985c13e500c3c70f337, reversing
changes made to a2d66c0fc8ee58e82be3efd59173803e66dee3e0.
I brought you into this world, and I can take you out.