Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add local babel workflow #25

Merged
merged 2 commits into from Nov 22, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
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