-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathrollup.config.mjs
More file actions
59 lines (54 loc) · 2 KB
/
rollup.config.mjs
File metadata and controls
59 lines (54 loc) · 2 KB
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
53
54
55
56
57
58
59
// rollup.config.js
// import { globbySync as globby } from 'globby';
import commonjs from '@rollup/plugin-commonjs';
import { nodeResolve } from '@rollup/plugin-node-resolve';
import nodePolyfills from 'rollup-plugin-polyfill-node';
import json from '@rollup/plugin-json';
// import copy from 'rollup-plugin-copy'
import { readFileSync } from 'fs';
const pkg = JSON.parse(readFileSync('./package.json'))
// const copyOpts = {
// targets: [
// { src: 'src/vendor/edge-fel/edge-fel.wasm', dest: 'dist' }
// ]
// }
export default [
// browser-friendly builds
{
input: 'src/index.js',
output: [{
name: 'edgeML',
file: pkg.browser['dist/index.js'], // from package.json
format: 'iife'
},
{
name: 'edgeML',
file: pkg.browser['dist/index.esm.js'], // from package.json
format: 'es'
}],
plugins: [
// copy(copyOpts),
nodeResolve({ preferBuiltins: true, browser: true }),
commonjs({ transformMixedEsModules: true, include: ["src/**", "node_modules/**"], strictRequires: true }), // so Rollup can convert to ES module
]
},
// CommonJS (for Node) and ES module (for bundlers) build.
// (We could have three entries in the configuration array
// instead of two, but it's quicker to generate multiple
// builds from a single configuration where possible, using
// an array for the `output` option, where we can specify
// `file` and `format` for each target)
{
input: 'src/index.js',
output: [
{ file: pkg.main, format: 'cjs' }, // from package.json
{ file: pkg.module, format: 'es' } // from package.json
],
plugins: [
// copy(copyOpts),
nodeResolve(),
json(),
commonjs({ transformMixedEsModules: true, include: ["src/**", "node_modules/**"], strictRequires: true }), // so Rollup can convert to ES module
]
},
];