-
-
Notifications
You must be signed in to change notification settings - Fork 647
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
15 changed files
with
200 additions
and
160 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,8 +1,5 @@ | ||
config/ | ||
scripts/ | ||
dist/ | ||
types/ | ||
docs/ | ||
types/ | ||
scripts/ | ||
.eslintrc.cjs | ||
index.js |
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
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,10 @@ | ||
import build from './build.js' | ||
import { resolvePath } from './utils.js' | ||
|
||
const fileName = 'main.cjs' | ||
const index = resolvePath('index.js') | ||
build({ | ||
index, | ||
fileName, | ||
format: 'cjs' | ||
}) |
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 @@ | ||
import build from './build.js' | ||
import { resolvePath } from './utils.js' | ||
|
||
const fileName = 'index.js' | ||
const index = resolvePath('index.ts', resolvePath('src')) | ||
|
||
build({ | ||
index, | ||
fileName, | ||
format: 'esm' | ||
}) |
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,15 @@ | ||
import build from './build.js' | ||
import { isDev, env } from './config.js' | ||
import { resolvePath } from './utils.js' | ||
|
||
const fileName = isDev ? 'klinecharts.js' : 'klinecharts.min.js' | ||
const index = resolvePath('index.ts', resolvePath('src')) | ||
|
||
build({ | ||
index, | ||
replaceValues: { "process.env.NODE_ENV": JSON.stringify(env) }, | ||
fileName, | ||
format: 'umd', | ||
parentDir: 'umd', | ||
name: 'klinecharts' | ||
}) |
This file was deleted.
Oops, something went wrong.
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,28 @@ | ||
import { rollup } from 'rollup' | ||
import chalk from 'chalk' | ||
|
||
import { createInputConfig, createOutputConfig, version, env } from './config.js' | ||
|
||
async function build({ index, replaceValues, fileName, format, parentDir, name }) { | ||
const text = `version ${version}${env ? ` ${env} `: ' '}${format} file` | ||
|
||
console.log(`Start building ${text}...\n`) | ||
|
||
try { | ||
const startTime = new Date().getTime() | ||
const bundle = await rollup(createInputConfig({ input: index, replaceValues })) | ||
|
||
await bundle.write(createOutputConfig({ | ||
fileName, format, name, parentDir | ||
})); | ||
|
||
console.log(chalk.green(`\n✔️ Compiled ${text} successfully.\n`)); | ||
console.log(`Done in ${((new Date().getTime() - startTime) / 1000 / 60).toFixed(2)}s.\n`) | ||
} catch (err) { | ||
console.log(`\n\n${chalk.red(err)}\n`); | ||
console.log(chalk.red(`✖️ Failed to compile ${text}.\n`)); | ||
process.exit(1); | ||
} | ||
} | ||
|
||
export default build |
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 was deleted.
Oops, something went wrong.
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,82 @@ | ||
import { nodeResolve } from '@rollup/plugin-node-resolve' | ||
import eslint from '@rollup/plugin-eslint' | ||
import replace from '@rollup/plugin-replace' | ||
// import commonjs from '@rollup/plugin-commonjs' | ||
import typescript from '@rollup/plugin-typescript' | ||
import terser from '@rollup/plugin-terser' | ||
import fileSize from 'rollup-plugin-filesize' | ||
import progress from 'rollup-plugin-progress' | ||
|
||
import { resolvePath, getVersion } from './utils.js' | ||
|
||
const version = getVersion() | ||
|
||
const env = process.env.NODE_ENV | ||
|
||
const isDev = env === 'development' | ||
|
||
const isProd = env === 'production' | ||
|
||
const buildDir = resolvePath('dist') | ||
|
||
function createInputConfig ({ input, replaceValues }) { | ||
return { | ||
input, | ||
plugins: [ | ||
typescript(), | ||
eslint({ | ||
throwOnError: true | ||
}), | ||
nodeResolve(), | ||
// commonjs(), | ||
progress(), | ||
replace({ | ||
preventAssignment: true, | ||
values: { | ||
'__VERSION__': version, | ||
...replaceValues | ||
} | ||
}), | ||
fileSize(), | ||
isProd && terser() | ||
].filter(p => !!p) | ||
} | ||
} | ||
|
||
function createOutputConfig ({ | ||
fileName, format, name, parentDir | ||
}) { | ||
let file | ||
if (parentDir) { | ||
file = resolvePath(fileName, resolvePath(parentDir, buildDir)) | ||
} else { | ||
file = resolvePath(fileName, buildDir) | ||
} | ||
const config = { | ||
file, | ||
format, | ||
sourcemap: isDev, | ||
indent: false, | ||
banner: ` | ||
/** | ||
* @license | ||
* KLineChart v${version} | ||
* Copyright (c) 2019 lihu. | ||
* Licensed under Apache License 2.0 https://www.apache.org/licenses/LICENSE-2.0 | ||
*/`.trim(), | ||
} | ||
|
||
if (!!name) { | ||
config.name = name | ||
} | ||
return config | ||
} | ||
|
||
export { | ||
createInputConfig, | ||
createOutputConfig, | ||
version, | ||
env, | ||
isDev, | ||
isProd | ||
} |
Oops, something went wrong.