-
Notifications
You must be signed in to change notification settings - Fork 11
/
Copy pathrollup.config.js
52 lines (45 loc) · 1.31 KB
/
rollup.config.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
import path from 'path';
import dts from 'rollup-plugin-dts';
import json from 'rollup-plugin-json';
import typescript from 'rollup-plugin-typescript';
import pkg from './package.json';
/**
* Get a list of the non-private sorted packages with Lerna v3
* @see https://github.com/lerna/lerna/issues/1848
* @return {Promise<Package[]>} List of packages
*/
async function main()
{
const results = [];
const namespaces = {};
namespaces[pkg.name] = pkg.namespace || 'feng3d';
for (const key in pkg.dependencies)
{
namespaces[key] = 'feng3d';
}
// Check for bundle folder
const external = Object.keys(pkg.dependencies || []);
const basePath = path.relative(__dirname, '');
const input = path.join(basePath, 'src/index.ts');
const {
standalone,
} = pkg;
const types = pkg.dts;
results.push({
input,
external: standalone ? [] : external,
output: [{
file: path.join(basePath, types),
name: namespaces[pkg.name],
format: 'es',
footer: `export as namespace ${namespaces[pkg.name]};`
}],
plugins: [
json(),
typescript({ tsconfig: './tsconfig.json' }),
dts({ respectExternal: true }),
],
});
return results;
}
export default main();