-
-
Notifications
You must be signed in to change notification settings - Fork 27
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
158 changed files
with
3,334 additions
and
5,395 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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(); | ||
}); | ||
}); | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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" | ||
] | ||
} |
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
Oops, something went wrong.