forked from jashkenas/underscore
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Generate Node.js build in two stages
This proved necessary in order to preserve all aliases in the new Node.js 12+ ESM entry point.
- Loading branch information
1 parent
45afe0e
commit 04b639c
Showing
11 changed files
with
265 additions
and
242 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -11,3 +11,4 @@ cjs | |
/underscore.js | ||
/underscore-min.js | ||
/underscore-min.js.map | ||
/underscore-node-*-pre* |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
import { readFileSync } from 'fs'; | ||
import { extend } from './underscore-esm.js'; | ||
|
||
var intro = readFileSync('modules/index.js', 'utf-8').split('\n').slice(3, 7).join('\n'); | ||
|
||
var outputBase = { | ||
strict: false, | ||
externalLiveBindings: false, | ||
freeze: false, | ||
}; | ||
|
||
var sourcemapBase = { | ||
sourcemap: true, | ||
sourcemapExcludeSources: true, | ||
}; | ||
|
||
export function outputConf(particular) { | ||
return extend(particular, outputBase); | ||
} | ||
|
||
export function sourcemapConf(particular) { | ||
return extend(particular, outputBase, sourcemapBase); | ||
} | ||
|
||
export function monolithConf(particular) { | ||
return extend(particular, outputBase, sourcemapBase, {intro}); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
import { resolve } from 'path'; | ||
import { monolithConf } from './rollup.common.js'; | ||
|
||
var sharedInput = './underscore-node-f-pre.js'; | ||
var sharedOutput = './underscore-node-f.cjs'; | ||
|
||
export default [ | ||
// ESM entry point for Node.js 12+. | ||
{ | ||
input: 'underscore-node-mjs-pre.js', | ||
external: sharedInput, | ||
output: monolithConf({ | ||
file: 'underscore-node.mjs', | ||
format: 'esm', | ||
paths: { | ||
[resolve(__dirname, sharedInput)]: sharedOutput, | ||
}, | ||
}), | ||
}, | ||
// CJS entry point for Node.js 12+, plus code shared with the ESM entry. | ||
{ | ||
input: { | ||
'underscore-node-f': sharedInput, | ||
'underscore-node': 'underscore-node-cjs-pre.js', | ||
}, | ||
preserveModules: true, | ||
output: monolithConf({ | ||
entryFileNames: '[name].cjs', | ||
dir: '.', | ||
exports: 'auto', | ||
format: 'cjs', | ||
}), | ||
}, | ||
]; |
Oops, something went wrong.