add 6to5-runtime build process #535
This commit is contained in:
parent
7257e2445d
commit
d75139a059
1
.gitignore
vendored
1
.gitignore
vendored
@ -11,3 +11,4 @@ test/tmp
|
|||||||
coverage
|
coverage
|
||||||
dist
|
dist
|
||||||
.package.json
|
.package.json
|
||||||
|
packages/6to5-runtime/*.js
|
||||||
|
|||||||
@ -12,3 +12,4 @@ CHANGELOG.md
|
|||||||
.package.json
|
.package.json
|
||||||
coverage
|
coverage
|
||||||
vendor
|
vendor
|
||||||
|
packages
|
||||||
|
|||||||
@ -18,6 +18,8 @@ _Note: Gaps between patch versions are faulty/broken releases._
|
|||||||
* Caching is now always enabled for the require hook. It also now no longer caches require resolutions.
|
* Caching is now always enabled for the require hook. It also now no longer caches require resolutions.
|
||||||
* `ignoreRegex` fallback has now been dropped from the require hook. `register(/foo/);`, `register({ ignoreRegex: /foo/ })` -> `register({ ignore: /foo/ })`.
|
* `ignoreRegex` fallback has now been dropped from the require hook. `register(/foo/);`, `register({ ignoreRegex: /foo/ })` -> `register({ ignore: /foo/ })`.
|
||||||
* Optional fast transformer backwards compatibility support has been removed. Use [loose mode](https://6to5.org/docs/usage/loose).
|
* Optional fast transformer backwards compatibility support has been removed. Use [loose mode](https://6to5.org/docs/usage/loose).
|
||||||
|
* Removed the optional runtime in favor of the `selfContained` transformer.
|
||||||
|
* Removed the `coreAliasing` transformer in favor of `selfContained`.
|
||||||
|
|
||||||
## 2.13.3
|
## 2.13.3
|
||||||
|
|
||||||
|
|||||||
21
Makefile
21
Makefile
@ -7,7 +7,7 @@ MOCHA_CMD = node_modules/mocha/bin/_mocha
|
|||||||
|
|
||||||
export NODE_ENV = test
|
export NODE_ENV = test
|
||||||
|
|
||||||
.PHONY: clean test test-cov test-clean lint test-travis test-simple test-all test-browser publish build bootstrap publish-core
|
.PHONY: clean test test-cov test-clean lint test-travis test-simple test-all test-browser publish build bootstrap publish-core publish-runtime
|
||||||
|
|
||||||
build:
|
build:
|
||||||
mkdir -p dist
|
mkdir -p dist
|
||||||
@ -20,9 +20,6 @@ build:
|
|||||||
node $(BROWSERIFY_CMD) lib/6to5/browser.js -s to5 >dist/6to5.js
|
node $(BROWSERIFY_CMD) lib/6to5/browser.js -s to5 >dist/6to5.js
|
||||||
node $(UGLIFY_CMD) dist/6to5.js >dist/6to5.min.js
|
node $(UGLIFY_CMD) dist/6to5.js >dist/6to5.min.js
|
||||||
|
|
||||||
node bin/6to5-runtime >dist/runtime.js
|
|
||||||
node $(UGLIFY_CMD) dist/runtime.js >dist/runtime.min.js
|
|
||||||
|
|
||||||
rm -rf templates.json
|
rm -rf templates.json
|
||||||
|
|
||||||
clean:
|
clean:
|
||||||
@ -78,7 +75,6 @@ publish:
|
|||||||
make build
|
make build
|
||||||
cp dist/6to5.min.js browser.js
|
cp dist/6to5.min.js browser.js
|
||||||
cp dist/polyfill.min.js browser-polyfill.js
|
cp dist/polyfill.min.js browser-polyfill.js
|
||||||
cp dist/runtime.min.js runtime.js
|
|
||||||
|
|
||||||
node bin/cache-templates
|
node bin/cache-templates
|
||||||
test -f templates.json
|
test -f templates.json
|
||||||
@ -87,19 +83,26 @@ publish:
|
|||||||
|
|
||||||
git push --follow-tags
|
git push --follow-tags
|
||||||
|
|
||||||
# generate
|
make publish-core
|
||||||
|
make publish-runtime
|
||||||
|
|
||||||
|
rm -rf templates.json browser.js browser-polyfill.js
|
||||||
|
|
||||||
|
publish-runtime:
|
||||||
|
cd packages; \
|
||||||
|
node build-runtime.js; \
|
||||||
|
npm publish
|
||||||
|
|
||||||
|
publish-core:
|
||||||
bin/generate-core-package-json >package2.json
|
bin/generate-core-package-json >package2.json
|
||||||
mv package.json .package.json
|
mv package.json .package.json
|
||||||
mv package2.json package.json
|
mv package2.json package.json
|
||||||
|
|
||||||
npm publish
|
npm publish
|
||||||
|
|
||||||
# restore
|
|
||||||
rm -rf package.json
|
rm -rf package.json
|
||||||
mv .package.json package.json
|
mv .package.json package.json
|
||||||
|
|
||||||
rm -rf templates.json browser.js runtime.js browser-polyfill.js
|
|
||||||
|
|
||||||
bootstrap:
|
bootstrap:
|
||||||
npm install
|
npm install
|
||||||
git submodule update --init
|
git submodule update --init
|
||||||
|
|||||||
@ -1,4 +0,0 @@
|
|||||||
#!/usr/bin/env node
|
|
||||||
|
|
||||||
var runtime = require("../lib/6to5/runtime-generator");
|
|
||||||
console.log(runtime(process.argv[2]));
|
|
||||||
@ -42,12 +42,6 @@ File.helpers = [
|
|||||||
"get"
|
"get"
|
||||||
];
|
];
|
||||||
|
|
||||||
File.excludeHelpersFromRuntime = [
|
|
||||||
"async-to-generator",
|
|
||||||
"typeof",
|
|
||||||
"tagged-template-literal-loose"
|
|
||||||
];
|
|
||||||
|
|
||||||
File.normaliseOptions = function (opts) {
|
File.normaliseOptions = function (opts) {
|
||||||
opts = _.cloneDeep(opts || {});
|
opts = _.cloneDeep(opts || {});
|
||||||
|
|
||||||
@ -214,7 +208,7 @@ File.prototype.addHelper = function (name) {
|
|||||||
|
|
||||||
var ref;
|
var ref;
|
||||||
var runtimeNamespace = this.opts.runtime;
|
var runtimeNamespace = this.opts.runtime;
|
||||||
if (runtimeNamespace && !_.contains(File.excludeHelpersFromRuntime, name)) {
|
if (runtimeNamespace) {
|
||||||
name = t.identifier(t.toIdentifier(name));
|
name = t.identifier(t.toIdentifier(name));
|
||||||
return t.memberExpression(t.identifier(runtimeNamespace), name);
|
return t.memberExpression(t.identifier(runtimeNamespace), name);
|
||||||
} else {
|
} else {
|
||||||
|
|||||||
@ -9,8 +9,6 @@ exports.version = require("../../package").version;
|
|||||||
|
|
||||||
exports.types = require("./types");
|
exports.types = require("./types");
|
||||||
|
|
||||||
exports.runtime = require("./runtime-generator");
|
|
||||||
|
|
||||||
exports.register = function (opts) {
|
exports.register = function (opts) {
|
||||||
var register = require("./register");
|
var register = require("./register");
|
||||||
if (opts != null) register(opts);
|
if (opts != null) register(opts);
|
||||||
|
|||||||
@ -1,35 +0,0 @@
|
|||||||
"use strict";
|
|
||||||
|
|
||||||
var generator = require("./generation/generator");
|
|
||||||
var util = require("./util");
|
|
||||||
var File = require("./file");
|
|
||||||
var t = require("./types");
|
|
||||||
var _ = require("lodash");
|
|
||||||
|
|
||||||
module.exports = function (namespace) {
|
|
||||||
namespace = t.identifier(t.toIdentifier(namespace || "to5Runtime"));
|
|
||||||
|
|
||||||
var body = [];
|
|
||||||
var container = t.functionExpression(null, [t.identifier("global")], t.blockStatement(body));
|
|
||||||
var tree = t.program([t.expressionStatement(t.callExpression(container, [util.template("self-global")]))]);
|
|
||||||
|
|
||||||
body.push(t.variableDeclaration("var", [
|
|
||||||
t.variableDeclarator(
|
|
||||||
namespace,
|
|
||||||
t.assignmentExpression("=", t.memberExpression(t.identifier("global"), namespace), t.objectExpression([]))
|
|
||||||
)
|
|
||||||
]));
|
|
||||||
|
|
||||||
_.each(File.helpers, function (name) {
|
|
||||||
if (_.contains(File.excludeHelpersFromRuntime, name)) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
var key = t.identifier(t.toIdentifier(name));
|
|
||||||
body.push(t.expressionStatement(
|
|
||||||
t.assignmentExpression("=", t.memberExpression(namespace, key), util.template(name))
|
|
||||||
));
|
|
||||||
});
|
|
||||||
|
|
||||||
return generator(tree).code;
|
|
||||||
};
|
|
||||||
@ -9,8 +9,7 @@
|
|||||||
"main": "lib/6to5/index.js",
|
"main": "lib/6to5/index.js",
|
||||||
"bin": {
|
"bin": {
|
||||||
"6to5": "./bin/6to5/index.js",
|
"6to5": "./bin/6to5/index.js",
|
||||||
"6to5-node": "./bin/6to5-node",
|
"6to5-node": "./bin/6to5-node"
|
||||||
"6to5-runtime": "./bin/6to5-runtime"
|
|
||||||
},
|
},
|
||||||
"browser": {
|
"browser": {
|
||||||
"./lib/6to5/index.js": "./lib/6to5/browser.js",
|
"./lib/6to5/index.js": "./lib/6to5/browser.js",
|
||||||
|
|||||||
6
packages/6to5-runtime/package.json
Normal file
6
packages/6to5-runtime/package.json
Normal file
@ -0,0 +1,6 @@
|
|||||||
|
{
|
||||||
|
"name": "6to5-runtime",
|
||||||
|
"description": "6to5 selfContained runtime",
|
||||||
|
"version": "2.13.3",
|
||||||
|
"author": "Sebastian McKenzie <sebmck@gmail.com>"
|
||||||
|
}
|
||||||
6
packages/README.md
Normal file
6
packages/README.md
Normal file
@ -0,0 +1,6 @@
|
|||||||
|
# What is this?
|
||||||
|
|
||||||
|
This is a folder containing additional packages that are built whenever
|
||||||
|
a new version of 6to5 is released.
|
||||||
|
|
||||||
|
**TODO:** Move `6to5-core` into here.
|
||||||
53
packages/build-runtime.js
Normal file
53
packages/build-runtime.js
Normal file
@ -0,0 +1,53 @@
|
|||||||
|
"use strict";
|
||||||
|
|
||||||
|
var transform = require("../lib/6to5/transformation/transform");
|
||||||
|
var File = require("../lib/6to5/file");
|
||||||
|
var util = require("../lib/6to5/util");
|
||||||
|
var fs = require("fs");
|
||||||
|
var t = require("../lib/6to5/types");
|
||||||
|
var _ = require("lodash");
|
||||||
|
|
||||||
|
var relative = function (filename) {
|
||||||
|
return __dirname + "/6to5-runtime/" + filename;
|
||||||
|
};
|
||||||
|
|
||||||
|
var writeFile = function (filename, content) {
|
||||||
|
filename = relative(filename);
|
||||||
|
console.log(filename);
|
||||||
|
fs.writeFileSync(filename, content);
|
||||||
|
};
|
||||||
|
|
||||||
|
var readFile = function (filename) {
|
||||||
|
return fs.readFileSync(require.resolve(filename), "utf8");
|
||||||
|
};
|
||||||
|
|
||||||
|
var updatePackage = function () {
|
||||||
|
var pkgLoc = relative("package.json");
|
||||||
|
var pkg = require(pkgLoc);
|
||||||
|
|
||||||
|
var mainPkg = require("../package.json");
|
||||||
|
pkg.version = mainPkg.version;
|
||||||
|
|
||||||
|
writeFile("package.json", JSON.stringify(pkg, null, 2));
|
||||||
|
};
|
||||||
|
|
||||||
|
var buildHelpers = function () {
|
||||||
|
var body = [];
|
||||||
|
var tree = t.program(body);
|
||||||
|
|
||||||
|
_.each(File.helpers, function (name) {
|
||||||
|
var key = t.identifier(t.toIdentifier(name));
|
||||||
|
body.push(t.expressionStatement(
|
||||||
|
t.assignmentExpression("=", t.memberExpression(t.identifier("exports"), key), util.template(name))
|
||||||
|
));
|
||||||
|
});
|
||||||
|
|
||||||
|
return transform.fromAst(tree, null, {
|
||||||
|
optional: ["selfContained"]
|
||||||
|
}).code;
|
||||||
|
};
|
||||||
|
|
||||||
|
writeFile("helpers.js", buildHelpers());
|
||||||
|
writeFile("core-js.js", readFile("core-js/library"));
|
||||||
|
writeFile("regenerator.js", readFile("core-js/library"));
|
||||||
|
updatePackage();
|
||||||
Loading…
x
Reference in New Issue
Block a user