Skip to content

Commit

Permalink
Add local babel workflow (#25)
Browse files Browse the repository at this point in the history
* Add local babel workflow

* update README
  • Loading branch information
jbhoosreddy authored and nicolo-ribaudo committed Nov 22, 2019
1 parent 87976f5 commit 63bad42
Show file tree
Hide file tree
Showing 4 changed files with 28 additions and 6 deletions.
6 changes: 6 additions & 0 deletions README.md
Expand Up @@ -30,6 +30,12 @@ If you want to run **all** the tests, run
node lib/run-tests I_AM_SURE
```

If you want to run against a local copy of babel repo (useful for debugging):

```
BABEL_PATH=../babel node lib/run-tests [pattern]
```

## Download babel/babel master test262 artifact

```
Expand Down
13 changes: 13 additions & 0 deletions lib/run-tests/contextualize-require.js
@@ -0,0 +1,13 @@
const path = require('path');

const babelPath = process.env.BABEL_PATH ?
path.resolve(process.cwd(), process.env.BABEL_PATH) :
undefined;

module.exports = function contextualizeRequire(path) {
if (!babelPath) {
return require(path);
}
const newPath = `${babelPath}/${path.replace('@babel/', 'packages/babel-')}`;
return require(newPath);
};
10 changes: 6 additions & 4 deletions lib/run-tests/get-babel-plugins.js
@@ -1,10 +1,12 @@
"use strict";

const requireBabel = require('./contextualize-require');

const featuresToPlugins = {
"class-fields-public": require("@babel/plugin-proposal-class-properties"),
"class-methods-private": require("@babel/plugin-proposal-private-methods"),
"numeric-separator-literal": require("@babel/plugin-proposal-numeric-separator"),
//"import.meta": require("@babel/plugin-syntax-import-meta"),
"class-fields-public": requireBabel("@babel/plugin-proposal-class-properties"),
"class-methods-private": requireBabel("@babel/plugin-proposal-private-methods"),
"numeric-separator-literal": requireBabel("@babel/plugin-proposal-numeric-separator"),
//"import.meta": requireBabel("@babel/plugin-syntax-import-meta"),
};

const defaultPlugins = [
Expand Down
5 changes: 3 additions & 2 deletions lib/run-tests/transpile.js
@@ -1,7 +1,8 @@
"use strict";

const { transformSync, loadOptions } = require("@babel/core");
const presetEnv = require("@babel/preset-env");
const requireBabel = require('./contextualize-require');
const { transformSync, loadOptions } = requireBabel("@babel/core");
const presetEnv = requireBabel("@babel/preset-env");

const getBabelPlugins = require("./get-babel-plugins");

Expand Down

0 comments on commit 63bad42

Please sign in to comment.