1- import { resolve } from 'path' ;
2- import { readFileSync } from 'fs' ;
3- import { extend , filter } from './underscore-esm.js' ;
41import glob from 'glob' ;
5-
6- var intro = readFileSync ( 'modules/index.js' , 'utf-8' ) . split ( '\n' ) . slice ( 3 , 7 ) . join ( '\n' ) ;
7-
8- var outputBase = {
9- strict : false ,
10- externalLiveBindings : false ,
11- freeze : false ,
12- } ;
13-
14- var monolithicBase = {
15- intro,
16- sourcemap : true ,
17- sourcemapExcludeSources : true ,
18- } ;
19-
20- function outputConf ( particular ) {
21- return extend ( particular , outputBase ) ;
22- }
23-
24- function monolithConf ( particular ) {
25- return extend ( particular , outputBase , monolithicBase ) ;
26- }
27-
28- function resolveModule ( id ) {
29- return resolve ( __dirname , 'modules' , id ) ;
30- }
2+ import { filter } from './underscore-esm.js' ;
3+ import { outputConf , sourcemapConf , monolithConf } from './rollup.common.js' ;
314
325export default [
336 // Monolithic ESM bundle for browsers and deno.
@@ -54,33 +27,18 @@ export default [
5427 noConflict : true ,
5528 } ) ,
5629 } ,
57- // Custom CJS build for new Node.js.
30+ // Custom builds for Node.js, first pass. Second pass in rollup.config2 .js.
5831 {
59- input : 'modules/index-default.js' ,
32+ input : {
33+ 'underscore-node-cjs-pre' : 'modules/index-default.js' ,
34+ 'underscore-node-mjs-pre' : 'modules/index-all.js' ,
35+ } ,
6036 treeshake : false ,
61- output : monolithConf ( {
62- entryFileNames : 'underscore-node.cjs' ,
63- chunkFileNames : 'underscore-node-[name].cjs' ,
37+ output : sourcemapConf ( {
38+ chunkFileNames : 'underscore-node-f-pre.js' ,
6439 dir : '.' ,
6540 minifyInternalExports : false ,
66- exports : 'auto' ,
67- format : 'cjs' ,
68- manualChunks : function ( path ) {
69- if ( ! path . match ( / i n d e x ( - d e f a u l t ) ? \. j s $ / ) ) return 'f' ;
70- } ,
71- } ) ,
72- } ,
73- // Custom ESM build for new Node.js. Thin layer on top of CJS build.
74- {
75- input : 'modules/index-all.js' ,
76- external : [ './index.js' , './index-default.js' ] ,
77- output : monolithConf ( {
78- file : 'underscore-node.mjs' ,
7941 format : 'esm' ,
80- paths : {
81- [ resolveModule ( 'index.js' ) ] : './underscore-node-f.cjs' ,
82- [ resolveModule ( 'index-default.js' ) ] : './underscore-node.cjs' ,
83- } ,
8442 } ) ,
8543 } ,
8644 // AMD and CJS versions of the individual modules for development
0 commit comments