-
Notifications
You must be signed in to change notification settings - Fork 1.3k
/
rollup-script-target-es6.mjs
44 lines (39 loc) · 1.4 KB
/
rollup-script-target-es6.mjs
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
// 1st party Rollup plugins
import { babel } from '@rollup/plugin-babel';
import resolve from '@rollup/plugin-node-resolve';
import { getBanner } from './rollup-get-banner.mjs';
import { moduleOptions } from './rollup-module-options.mjs';
import { spacesToTabs } from './rollup-spaces-to-tabs.mjs';
/** @typedef {import('rollup').RollupOptions} RollupOptions */
/** @typedef {import('rollup').OutputOptions} OutputOptions */
/**
* Build an ES6 target that rollup is supposed to build.
*
* @param {string} name - The name, like `pcx` or `VoxParser`.
* @param {string} input - The input file, like `extras/index.js`.
* @param {string} output - The output file, like `build/playcanvas-extras.mjs`.
* @param {Boolean} [shouldBundle] - Whether the target should be bundled.
* @returns {RollupOptions} One rollup target.
*/
function scriptTargetEs6(name, input, output, shouldBundle = false) {
/** @type {OutputOptions} */
const outputOptions = {
name: name,
banner: getBanner(''),
format: 'es',
indent: '\t',
preserveModules: !shouldBundle
};
outputOptions[shouldBundle ? 'file' : 'dir'] = output;
return {
input: input,
output: outputOptions,
plugins: [
resolve(),
babel(moduleOptions('release')),
spacesToTabs(true)
],
external: ['playcanvas', 'fflate']
};
}
export { scriptTargetEs6 };