2019-09-18 14:05:16 +00:00
|
|
|
import { join, sep } from 'path';
|
2019-09-17 12:45:15 +00:00
|
|
|
import commonjs from 'rollup-plugin-commonjs';
|
|
|
|
import json from 'rollup-plugin-json';
|
|
|
|
import multiEntry from 'rollup-plugin-multi-entry';
|
|
|
|
import replace from 'rollup-plugin-replace';
|
|
|
|
import resolve from 'rollup-plugin-node-resolve';
|
|
|
|
import tslint from 'rollup-plugin-tslint';
|
|
|
|
import typescript from 'rollup-plugin-typescript2';
|
2019-09-28 09:25:07 +00:00
|
|
|
import yaml from 'rollup-plugin-yaml';
|
2019-09-17 12:45:15 +00:00
|
|
|
|
|
|
|
const metadata = require('../package.json');
|
2019-09-18 12:32:45 +00:00
|
|
|
const namedExports = require('./rollup-named.json');
|
2019-09-17 12:45:15 +00:00
|
|
|
|
2019-09-18 13:35:45 +00:00
|
|
|
const rootPath = process.env['ROOT_PATH'];
|
|
|
|
const targetPath = process.env['TARGET_PATH'];
|
|
|
|
|
2019-09-17 12:45:15 +00:00
|
|
|
const bundle = {
|
|
|
|
external: [
|
|
|
|
'async_hooks',
|
|
|
|
'chai',
|
|
|
|
'sinon',
|
|
|
|
],
|
|
|
|
input: [
|
2019-09-18 14:05:16 +00:00
|
|
|
join(rootPath, 'src', 'index.ts'),
|
|
|
|
join(rootPath, 'test', 'harness.ts'),
|
|
|
|
join(rootPath, 'test', '**', 'Test*.ts'),
|
2019-09-17 12:45:15 +00:00
|
|
|
],
|
|
|
|
manualChunks(id) {
|
2019-09-18 14:05:16 +00:00
|
|
|
if (id.includes(`${sep}test${sep}`)) {
|
2019-09-17 12:45:15 +00:00
|
|
|
return 'test'
|
|
|
|
}
|
|
|
|
|
2019-09-18 14:05:16 +00:00
|
|
|
if (id.includes(`${sep}node_modules${sep}`)) {
|
2019-09-17 12:45:15 +00:00
|
|
|
return 'vendor';
|
|
|
|
}
|
|
|
|
|
2019-09-18 14:05:16 +00:00
|
|
|
if (id.includes(`${sep}src${sep}index`)) {
|
2019-09-17 12:45:15 +00:00
|
|
|
return 'index';
|
|
|
|
}
|
|
|
|
|
2019-09-18 14:05:16 +00:00
|
|
|
if (id.includes(`${sep}src${sep}`)) {
|
2019-09-17 12:45:15 +00:00
|
|
|
return 'main';
|
|
|
|
}
|
|
|
|
},
|
|
|
|
output: {
|
2019-09-18 12:32:45 +00:00
|
|
|
dir: targetPath,
|
2019-09-17 12:45:15 +00:00
|
|
|
chunkFileNames: '[name].js',
|
|
|
|
entryFileNames: 'entry-[name].js',
|
|
|
|
format: 'cjs',
|
|
|
|
sourcemap: true,
|
|
|
|
},
|
|
|
|
plugins: [
|
|
|
|
multiEntry(),
|
|
|
|
json(),
|
2019-09-28 09:25:07 +00:00
|
|
|
yaml(),
|
2019-09-17 12:45:15 +00:00
|
|
|
replace({
|
|
|
|
delimiters: ['{{ ', ' }}'],
|
|
|
|
values: {
|
|
|
|
BUILD_JOB: process.env['CI_JOB_ID'],
|
|
|
|
BUILD_RUNNER: process.env['CI_RUNNER_DESCRIPTION'],
|
|
|
|
GIT_BRANCH: process.env['CI_COMMIT_REF_SLUG'],
|
|
|
|
GIT_COMMIT: process.env['CI_COMMIT_SHA'],
|
|
|
|
NODE_VERSION: process.env['NODE_VERSION'],
|
2019-09-17 13:57:45 +00:00
|
|
|
PACKAGE_NAME: metadata.name,
|
|
|
|
PACKAGE_VERSION: metadata.version,
|
2019-09-17 12:45:15 +00:00
|
|
|
},
|
|
|
|
}),
|
|
|
|
resolve({
|
|
|
|
preferBuiltins: true,
|
|
|
|
}),
|
|
|
|
commonjs({
|
|
|
|
namedExports,
|
|
|
|
}),
|
|
|
|
tslint({
|
2019-09-18 13:35:45 +00:00
|
|
|
configuration: require('./tslint.json'),
|
2019-09-28 09:25:07 +00:00
|
|
|
exclude: [
|
|
|
|
`node_modules${sep}**`,
|
|
|
|
`src${sep}resource`,
|
|
|
|
`src${sep}**${sep}*.json`,
|
|
|
|
`src${sep}**${sep}*.yml`,
|
|
|
|
],
|
2019-09-17 12:45:15 +00:00
|
|
|
throwOnError: true,
|
|
|
|
}),
|
|
|
|
typescript({
|
2019-09-18 13:35:45 +00:00
|
|
|
cacheRoot: join(targetPath, 'cache/rts2'),
|
2019-09-17 12:45:15 +00:00
|
|
|
rollupCommonJSResolveHack: true,
|
|
|
|
}),
|
|
|
|
],
|
|
|
|
};
|
|
|
|
|
|
|
|
export default [
|
|
|
|
bundle,
|
|
|
|
];
|