Skip to content

Commit 130dc43

Browse files
committed
chore(build): publish es6 assets to npm
This includes an addition folder, es6, with an ES6 version of the library. This is particularly useful for tools like rollup.
1 parent 3f5bcaa commit 130dc43

5 files changed

+57
-7
lines changed

package.json

+6-3
Original file line numberDiff line numberDiff line change
@@ -3,11 +3,14 @@
33
"version": "2.0.0-alpha.15",
44
"description": "",
55
"main": "./dist/angularfire2.js",
6+
"jsnext:main": "./dist/es6/angularfire2.js",
67
"scripts": {
78
"test": "npm run build; karma start",
89
"docs": "typedoc --out docs/api/ --module commonjs --mode modules --name AngularFire2 src",
9-
"build": "rm -rf dist; tsc && cp package.json README.md LICENSE .npmignore dist/",
10-
"postbuild": "node tools/rewrite-published-package.js",
10+
"build": "rm -rf dist; tsc",
11+
"build_npm": "rm -rf dist && tsc -p tsconfig.publish.es5.json && tsc -p tsconfig.publish.es6.json",
12+
"postbuild_npm": "cp package.json README.md .npmignore dist/ && npm run rewrite_npm_package",
13+
"rewrite_npm_package": "node --harmony_destructuring tools/rewrite-published-package.js",
1114
"build_bundle": "cp -r src angularfire2 && tsc typings/main.d.ts angularfire2.ts --rootDir . --module system -t es5 --outFile dist/bundles/angularfire2.js --moduleResolution node --emitDecoratorMetadata --experimentalDecorators"
1215
},
1316
"keywords": [
@@ -54,7 +57,7 @@
5457
"traceur": "0.0.96",
5558
"tsd": "^0.6.5",
5659
"typedoc": "github:jeffbcross/typedoc",
57-
"typescript": "1.7.5",
60+
"typescript": "1.8.9",
5861
"typings": "^0.6.2",
5962
"zone.js": "^0.6.6"
6063
},

publish.sh

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,2 @@
1-
npm run build
1+
npm run build_npm
22
npm publish dist

tools/rewrite-published-package.js

+5-3
Original file line numberDiff line numberDiff line change
@@ -5,11 +5,13 @@
55
*/
66
var fs = require('fs');
77
var srcPackage = require('../package.json');
8+
var [MAIN, JSNEXT_MAIN] = ['main', 'jsnext:main'].map(k => srcPackage[k].replace('/dist/', '/'));
89
var outPackage = Object.assign({}, srcPackage, {
910
peerDependencies: srcPackage.dependencies,
10-
main: "angularfire2.js",
11-
typings: "angularfire2.d.ts"
11+
main: MAIN,
12+
typings: "angularfire2.d.ts",
13+
"jsnext:main": JSNEXT_MAIN,
14+
dependencies: undefined
1215
});
13-
delete outPackage.dependencies;
1416

1517
fs.writeFileSync('./dist/package.json', JSON.stringify(outPackage, null, 2));

tsconfig.publish.es5.json

+22
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
{
2+
"compilerOptions": {
3+
"experimentalDecorators": true,
4+
"emitDecoratorMetadata": true,
5+
"module": "commonjs",
6+
"target": "es5",
7+
"noImplicitAny": true,
8+
"outDir": "dist",
9+
"rootDir": "src",
10+
"sourceMap": true,
11+
"declaration": true,
12+
"removeComments": true
13+
},
14+
"files": [
15+
"src/angularfire2.ts",
16+
"src/angularfire2_worker_app.ts",
17+
"src/angularfire2_worker_render.ts",
18+
"src/utils/absolute_path_resolver.ts",
19+
"src/utils/firebase_object_factory.ts",
20+
"typings/main.d.ts"
21+
]
22+
}

tsconfig.publish.es6.json

+23
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
{
2+
"compilerOptions": {
3+
"experimentalDecorators": true,
4+
"emitDecoratorMetadata": true,
5+
"target": "es6",
6+
"noImplicitAny": true,
7+
"outDir": "dist/es6",
8+
"rootDir": "src",
9+
"sourceMap": true,
10+
"declaration": true,
11+
"removeComments": true,
12+
"moduleResolution": "node"
13+
},
14+
"files": [
15+
"src/angularfire2.ts",
16+
"src/angularfire2_worker_app.ts",
17+
"src/angularfire2_worker_render.ts",
18+
"src/utils/absolute_path_resolver.ts",
19+
"src/utils/firebase_object_factory.ts",
20+
"typings/main/ambient/firebase/firebase.d.ts",
21+
"typings/main/ambient/jasmine/jasmine.d.ts"
22+
]
23+
}

0 commit comments

Comments
 (0)