-
Notifications
You must be signed in to change notification settings - Fork 7
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
93e324e
commit bc4595d
Showing
19 changed files
with
2,681 additions
and
1,340 deletions.
There are no files selected for viewing
This file contains 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 |
---|---|---|
@@ -1,21 +1,20 @@ | ||
// vim:ft=javascript | ||
{ | ||
sourceMaps: 'inline', | ||
env: { | ||
development: { | ||
sourceMaps: 'inline', | ||
} | ||
}, | ||
|
||
presets: [ | ||
['env', { | ||
['@babel/preset-env', { | ||
// only include polyfills if they're used | ||
useBuiltIns: 'usage', | ||
|
||
/* | ||
* add polyfills for Object.assign, Promise &c. to bring the supported | ||
* target up to ES2015 compatibility. | ||
* | ||
* set debug to true to see what's added. | ||
*/ | ||
useBuiltIns: true, | ||
// set this to true to see the applied transforms and bundled polyfills | ||
debug: false, | ||
|
||
targets: { 'node': 4 }, | ||
loose: false, | ||
targets: { node: 4 }, // same as Babel 7 | ||
}], | ||
], | ||
} |
This file contains 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 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 |
---|---|---|
|
@@ -5,3 +5,4 @@ node_js: | |
- '4' | ||
- '6' | ||
- '8' | ||
- '9' |
This file contains 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 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 |
---|---|---|
|
@@ -29,7 +29,7 @@ A Babel plugin which automatically makes stack traces source-map aware | |
import foo from 'foo'; | ||
import bar from 'bar'; | ||
|
||
test(); | ||
foo(bar); | ||
``` | ||
|
||
`$ babel --plugins source-map-support test.js` | ||
|
@@ -39,7 +39,7 @@ import 'source-map-support/register'; | |
import foo from 'foo'; | ||
import bar from 'bar'; | ||
|
||
test(); | ||
foo(bar); | ||
``` | ||
|
||
# DESCRIPTION | ||
|
@@ -62,6 +62,23 @@ though it's harmless in other environments. | |
The source-map-support module only needs to be registered in the top-level file(s) of an application, | ||
but it no-ops if it has already been loaded, so there is no harm in registering it in every file. | ||
|
||
You probably don't want to use this plugin when compiling code for the web because you probably don't | ||
want to include inline source maps in minified code. An easy way to limit the plugin's use to | ||
development/test builds, is to use Babel's [`env` option](https://babeljs.io/docs/usage/babelrc/#env-option) e.g.: | ||
|
||
```javascript | ||
{ | ||
env: { | ||
development: { | ||
sourceMaps: 'inline', | ||
plugins: ['source-map-support', ...] | ||
} | ||
}, | ||
|
||
presets: [ ... ] | ||
} | ||
``` | ||
|
||
## CAVEATS | ||
|
||
Source maps must currently be inline. While the source-map-support module provides a way | ||
|
@@ -74,35 +91,35 @@ this plugin. | |
|
||
The following NPM scripts are available: | ||
|
||
* build - compile the plugin and save it to the target directory | ||
* test - compile the plugin and run the test suite | ||
* test:debug - compile the plugin and run the test suite in debug mode (which dumps each transformed test case) | ||
* release - run the test script in production mode, which compiles the plugin for release | ||
* test - lint the codebase, compile the plugin, and run the test suite | ||
* test:debug - run the test script in debug mode, which dumps each transformed test case | ||
|
||
## Gulp Tasks | ||
|
||
The following Gulp tasks are available: | ||
|
||
* build - compile the plugin and save it to the target directory | ||
* clean - remove the target directory and its contents | ||
* default - alias for the `build` task | ||
* default - run the `clean`, `lint` and `build` tasks | ||
* lint - check and report style and usage errors in the gulpfile, source file(s) and test file(s) | ||
|
||
# SEE ALSO | ||
|
||
* [babel](https://www.npmjs.com/package/babel) | ||
* [babel-plugin-transform-es2015-modules-commonjs-simple](https://www.npmjs.com/package/babel-plugin-transform-es2015-modules-commonjs-simple) | ||
* [source-map-support](https://www.npmjs.com/package/source-map-support) | ||
|
||
# VERSION | ||
|
||
1.0.0 | ||
2.0.0 | ||
|
||
# AUTHOR | ||
|
||
[chocolateboy](mailto:[email protected]) | ||
|
||
# COPYRIGHT AND LICENSE | ||
|
||
Copyright © 2015-2017 by chocolateboy | ||
Copyright © 2015-2018 by chocolateboy | ||
|
||
This module is free software; you can redistribute it and/or modify it under the | ||
terms of the [Artistic License 2.0](http:https://www.opensource.org/licenses/artistic-license-2.0.php). |
This file contains 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 |
---|---|---|
@@ -1,32 +1,35 @@ | ||
const del = require('del') | ||
const gulp = require('gulp') | ||
const babel = require('gulp-babel') | ||
const eslint = require('gulp-eslint') | ||
|
||
const config = (function () { | ||
const srcDir = 'src' | ||
|
||
return { | ||
isDev: process.env.NODE_ENV === 'development', | ||
paths: { | ||
srcDir, | ||
destDir: 'dist', | ||
src: { | ||
js: `${srcDir}/**/*.js` | ||
} | ||
} | ||
const config = { | ||
isDev: process.env.NODE_ENV === 'development', | ||
paths: { | ||
destDir: 'dist', | ||
src: `src/**/*.js`, | ||
test: `test/*.js`, | ||
} | ||
})() | ||
} | ||
|
||
// compile the plugin and save it to the target directory | ||
gulp.task('build', () => { | ||
return gulp.src(config.paths.src) | ||
.pipe(babel()) | ||
.pipe(gulp.dest(config.paths.destDir)) | ||
}) | ||
|
||
// delete the target directory | ||
gulp.task('clean', () => { | ||
return del(config.paths.destDir) | ||
}) | ||
|
||
// compile the plugin and save it to the target directory | ||
gulp.task('build', () => { | ||
return gulp.src(config.paths.src.js) | ||
.pipe(babel()) | ||
.pipe(gulp.dest(config.paths.destDir)) | ||
// check for violations of style and usage rules | ||
gulp.task('lint', () => { | ||
return gulp.src([__filename, config.paths.src, config.paths.test]) | ||
.pipe(eslint()) | ||
.pipe(eslint.format()) // dump invalid code | ||
.pipe(eslint.failAfterError()) // exit with an error code on lint errors | ||
}) | ||
|
||
gulp.task('default', gulp.task('build')) | ||
gulp.task('default', gulp.series('clean', 'lint', 'build')) |
This file contains 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 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,13 @@ | ||
import { addSideEffect } from '@babel/helper-module-imports' | ||
|
||
const IMPORT = 'source-map-support/register' | ||
|
||
export default function babelPluginSourceMapSupport () { | ||
return { | ||
visitor: { | ||
Program (path) { | ||
addSideEffect(path, IMPORT) | ||
} | ||
} | ||
} | ||
} |
Oops, something went wrong.