Skip to content

Commit 4c64550

Browse files
author
Sepand Parhami
authored
Merge pull request #3 from sparhami/build
Add dist build configuration.
2 parents 817768f + eee3aaa commit 4c64550

File tree

7 files changed

+235
-11
lines changed

7 files changed

+235
-11
lines changed

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,3 @@
11
node_modules/
22
dist/
3+
build/

compile/externs.js

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
/**
2+
* @typedef {{
3+
* x1: number,
4+
* y1: number,
5+
* x2: number,
6+
* y2: number,
7+
* }}
8+
*/
9+
let Curve;
10+
11+
/**
12+
* @param {{
13+
* transitionContainer: HTMLElement,
14+
* styleContainer: HTMLElement,
15+
* srcImg: HTMLImageElement,
16+
* targetImg: HTMLImageElement,
17+
* srcImgRect: ClientRect,
18+
* targetImgRect: ClientRect,
19+
* curve: Curve,
20+
* styles: Object,
21+
* keyframesNamespace: string,
22+
* }} options
23+
* @return {{
24+
* applyAnimation: function(),
25+
* cleanupAnimation: function(),
26+
* }}
27+
*/
28+
window.prepareImageAnimation = function(options) {}
29+

compile/index.js

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
goog.module('global-entry-point');
2+
3+
const {prepareImageAnimation} = goog.require('index');
4+
5+
window['prepareImageAnimation'] = prepareImageAnimation;
6+

package-lock.json

Lines changed: 175 additions & 5 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 14 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,20 +2,29 @@
22
"name": "@ampproject/animations",
33
"version": "0.0.1",
44
"description": "JavaScript animation functions and helpers.",
5-
"main": "index.js",
5+
"main": "dist/src/animations.js",
6+
"module": "dist/src/animations.mjs",
67
"scripts": {
7-
"build": "tsc",
8+
"build": "tsc -p tsconfig-es6.json",
89
"build-watch": "npm run build -- --watch",
10+
"clean": "rm -rf dist/ build/",
11+
"compile": "mkdir -p dist && node_modules/google-closure-compiler/cli.js -O ADVANCED --js='compile/index.js' --js='build/**.js' --js='!build/**/test-*.js' --js='!build/src/testing/**' --externs='compile/externs.js' --rewrite_polyfills=false > build/closure-output.js",
12+
"create-mjs": "cp build/closure-output.js dist/animations.mjs && sed -i 's;window.\\([^=]*=\\);export const \\1;g' dist/animations.mjs",
13+
"create-cjs": "cp build/closure-output.js dist/animations.js && sed -i 's;window.\\([^=]*=\\);exports.\\1;g' dist/animations.js",
14+
"create-global": "npm run tsickle && npm run compile",
15+
"dist": "npm run clean && npm run create-global && npm run create-mjs && npm run create-cjs && npm run build",
916
"karma": "karma start --browsers Chrome,Firefox karma.conf.js",
1017
"test": "npm run karma -- --single-run",
11-
"test-watch": "npm run karma -- --auto-watch"
18+
"test-watch": "npm run karma -- --auto-watch",
19+
"tsickle": "node_modules/tsickle/src/main.js"
1220
},
1321
"author": "The AMP HTML Authors",
1422
"license": "Apache-2.0",
1523
"devDependencies": {
1624
"@types/chai": "^4.1.6",
1725
"@types/mocha": "^5.2.5",
1826
"chai": "^4.2.0",
27+
"google-closure-compiler": "^20181008.0.0",
1928
"karma": "^3.0.0",
2029
"karma-chai": "^0.1.0",
2130
"karma-chrome-launcher": "^2.2.0",
@@ -24,7 +33,8 @@
2433
"karma-mocha": "^1.3.0",
2534
"karma-typescript": "^3.0.13",
2635
"mocha": "^5.2.0",
27-
"typescript": "^3.1.2"
36+
"tsickle": "^0.33.0",
37+
"typescript": "git://github.com/mprobst/TypeScript.git#5456479a4a"
2838
},
2939
"dependencies": {}
3040
}

tsconfig-es6.json

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
{
2+
"_comment": "Tsickle requires tsconfig.json has module: commonjs and does not work if placed in a subdirectory.",
3+
"extends": "./tsconfig.json",
4+
"compilerOptions": {
5+
"outDir": "dist",
6+
"module": "es6",
7+
},
8+
}

tsconfig.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
{
22
"compilerOptions": {
33
"rootDir": ".",
4-
"outDir": "dist",
4+
"outDir": "build",
55
"allowSyntheticDefaultImports": false,
66
"allowUnreachableCode": false,
77
"allowUnusedLabels": false,
@@ -13,7 +13,7 @@
1313
"noImplicitReturns": true,
1414
"pretty": true,
1515
"strict": true,
16-
"module": "es6",
16+
"module": "commonjs",
1717
"target": "es2015",
1818
"lib": ["es2015", "dom"],
1919
"sourceMap": true

0 commit comments

Comments
 (0)