Skip to content

Commit

Permalink
Merge branch 'bigopon-master'
Browse files Browse the repository at this point in the history
  • Loading branch information
zewa666 committed Nov 2, 2018
2 parents f843bb1 + 6177346 commit b1d4e64
Show file tree
Hide file tree
Showing 158 changed files with 3,334 additions and 5,395 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ test/coverage-jest/
.DS_STORE
.DS_Store
.vscode/
.rollupcache
dist/doc-temp
jspm_packages
bower_components
Expand Down
11 changes: 11 additions & 0 deletions .npmignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
.circleci
.rollupcache
doc
build
node_modules
src
.gitignore
.npmignore
CONTRIBUTING.md
ISSUE_TEMPLATE.md
tsconfig.json
23 changes: 23 additions & 0 deletions build/args.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
import yargs from "yargs";
import { IBuildTargetFormat } from "./shared";

// tslint:disable-next-line:interface-name
export interface IArguments {
target: string;
format: IBuildTargetFormat[];
}

export const args: IArguments = yargs
.options(
"target",
{
alias: "t",
description: "target module dir to copy build results into (eg. \"--target ../other-module\" to copy build results into \"../other-module/node_modules/this-module/dist/…\" whenever they change)"
}
)
.options("format", {
alias: "f",
array: true,
description: "format to compile to (eg. \"es2015\", \"commonjs\", …). Can be set muliple times to compile to multiple formats. Default is all formats."
})
.argv as any;
46 changes: 46 additions & 0 deletions build/build.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
import rollup from "rollup";
import { build, generateDts, IBuildTargetFormat } from "./shared";
import { args } from "./args";
import packageJson from "../package.json";

const LIB_NAME = "aurelia-store";
const ENTRY_PATH = "src/aurelia-store.ts";
const EXTERNAL_LIBS = Object
.keys({ ...packageJson.dependencies, ...packageJson.devDependencies })
.filter(dev => /^(?:aurelia|rxjs)/.test(dev))
// rxjs/operators is considered a different module
// and cannot be resolved by rollup. Add this to avoid warning
.concat("rxjs/operators");
const configs = {
es2017: {
input: ENTRY_PATH,
outputs: [
{ file: "dist/es2017/index.js", format: "es" }
]
},
es2015: {
input: ENTRY_PATH,
outputs: [
{ file: "dist/es2015/index.js", format: "es" }
]
},
es5: {
input: ENTRY_PATH,
outputs: [
{ file: "dist/commonjs/index.js", format: "cjs" },
{ file: "dist/amd/index.js", format: "amd", amd: { id: LIB_NAME } },
{ file: "dist/native-modules/index.js", format: "es" }
]
}
}

const targetFormats: IBuildTargetFormat[] = args.format || ["es5", "es2015", "es2017"];
Promise
.all(targetFormats.map(target => {
const { outputs, ...options } = configs[target];
return build(target, { ...options, external: EXTERNAL_LIBS }, outputs as rollup.OutputOptionsFile[]);
}))
.then(() => generateDts())
.catch(ex => {
console.log(ex);
});
61 changes: 61 additions & 0 deletions build/shared.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
import * as rollup from "rollup";
import typescript from "rollup-plugin-typescript2";
import rimraf from "rimraf";
import ChildProcess from "child_process";


export type IBuildTargetFormat = "es5" | "es2015" | "es2017";

export async function build(
target: IBuildTargetFormat,
options: rollup.RollupFileOptions,
outputs: rollup.OutputOptionsFile[]
): Promise<void> {
return rollup
.rollup({
...options,
plugins: [
typescript({
tsconfigOverride: {
compilerOptions: {
target: target
}
},
cacheRoot: ".rollupcache"
}) as rollup.Plugin,
...(options.plugins || []),
]
})
.then(bundle => Promise.all(outputs.map(output => bundle.write(output))))
.then(() => {
console.log(`Built [${target}] successfully.`);
});
}

export async function clean(): Promise<void> {
console.log("\n==============\nCleaning dist folder...\n==============");
return new Promise<void>(resolve => {
rimraf("dist", (error) => {
if (error) {
throw error;
}
resolve();
});
});
}

export async function generateDts(): Promise<void> {
console.log("\n==============\nGenerating dts bundle...\n==============");
return new Promise<void>(resolve => {
ChildProcess.exec("npm run bundle-dts", (err, stdout, stderr) => {
if (err || stderr) {
console.log("Generating dts error:");
console.log(stderr);
} else {
console.log("Generated dts bundle successfully");
console.log(stdout);
}
resolve();
});
});
};
13 changes: 13 additions & 0 deletions build/tsconfig.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
{
"extends": "../tsconfig.json",
"compilerOptions": {
"module": "commonjs",
"target": "es2017",
"noEmit": true,
"esModuleInterop": true,
"resolveJsonModule": true
},
"include": [
"./**/*.ts"
]
}
13 changes: 0 additions & 13 deletions dist/amd/aurelia-store.d.ts

This file was deleted.

27 changes: 0 additions & 27 deletions dist/amd/aurelia-store.js

This file was deleted.

1 change: 0 additions & 1 deletion dist/amd/aurelia-store.js.map

This file was deleted.

13 changes: 0 additions & 13 deletions dist/amd/decorator.d.ts

This file was deleted.

102 changes: 0 additions & 102 deletions dist/amd/decorator.js

This file was deleted.

1 change: 0 additions & 1 deletion dist/amd/decorator.js.map

This file was deleted.

Loading

0 comments on commit b1d4e64

Please sign in to comment.