@@ -22,6 +22,8 @@ import pkgJSON from './package.json';
22
22
import { rewriteFilenames } from './Utilities/rollup/plugin-rewrite-filenames' ;
23
23
import { generateDtsReferences } from './Utilities/rollup/plugin-generate-references' ;
24
24
25
+ const fs = require ( 'fs' ) ;
26
+
25
27
const relatifyImports = require ( './Utilities/build/rewrite-imports' ) ;
26
28
27
29
const IGNORE_LIST = [
@@ -44,7 +46,6 @@ function ignoreFile(name, ignoreList = IGNORE_LIST) {
44
46
45
47
const entryPoints = [
46
48
path . join ( 'Sources' , 'macros.js' ) ,
47
- path . join ( 'Sources' , 'vtk.js' ) ,
48
49
path . join ( 'Sources' , 'favicon.js' ) ,
49
50
...glob . sync ( 'Sources/**/*.js' ) . filter ( ( file ) => ! ignoreFile ( file ) ) ,
50
51
] ;
@@ -59,7 +60,8 @@ const outputDir = path.resolve('dist', 'esm');
59
60
const dependencies = Object . keys ( pkgJSON . dependencies || [ ] ) ;
60
61
const peerDependencies = Object . keys ( pkgJSON . peerDependencies || [ ] ) ;
61
62
62
- export default {
63
+ export default [
64
+ {
63
65
input : entries ,
64
66
output : {
65
67
dir : outputDir ,
@@ -105,9 +107,6 @@ export default {
105
107
...peerDependencies . map ( ( name ) => new RegExp ( `^${ name } ` ) ) ,
106
108
] ,
107
109
plugins : [
108
- alias ( {
109
- entries : [ { find : 'vtk.js' , replacement : path . resolve ( __dirname ) } ] ,
110
- } ) ,
111
110
// ignore crypto module
112
111
ignore ( [ 'crypto' ] ) ,
113
112
// needs to be before nodeResolve
@@ -249,4 +248,51 @@ export default {
249
248
] ,
250
249
} ) ,
251
250
] ,
252
- } ;
251
+ } ,
252
+ {
253
+ input : path . resolve ( path . join ( 'Sources' , 'vtk.js' ) ) ,
254
+ output : {
255
+ dir : outputDir ,
256
+ format : 'es' ,
257
+ hoistTransitiveImports : false ,
258
+ intro ( ) {
259
+ return `/* ${ fs . readFileSync (
260
+ path . resolve ( __dirname , './LICENSE' ) ,
261
+ 'utf8'
262
+ ) } */`;
263
+ } ,
264
+ manualChunks ( id ) {
265
+ // strip out full path to project root
266
+ return id . replace ( `${ path . resolve ( __dirname ) } ${ path . sep } ` , '' ) ;
267
+ } ,
268
+ } ,
269
+ external : [
270
+ ...dependencies . map ( ( name ) => new RegExp ( `^${ name } ` ) ) ,
271
+ ...peerDependencies . map ( ( name ) => new RegExp ( `^${ name } ` ) ) ,
272
+ ] ,
273
+ plugins : [
274
+ alias ( {
275
+ entries : [ { find : 'vtk.js' , replacement : path . resolve ( __dirname ) } ] ,
276
+ } ) ,
277
+ nodeResolve ( {
278
+ // don't rely on node builtins for web
279
+ preferBuiltins : false ,
280
+ browser : true ,
281
+ } ) ,
282
+ ! process . env . NOLINT &&
283
+ eslint ( {
284
+ include : '**/*.js' ,
285
+ } ) ,
286
+ // commonjs should be before babel
287
+ commonjs ( {
288
+ transformMixedEsModules : true ,
289
+ } ) ,
290
+ // should be after commonjs
291
+ nodePolyfills ( ) ,
292
+ babel ( {
293
+ extensions : [ '.js' ] ,
294
+ babelHelpers : 'runtime' ,
295
+ } ) ,
296
+ ] ,
297
+ } ,
298
+ ] ;
0 commit comments