11import { readFileSync } from 'fs' ;
2- import path from 'path' ;
2+ import { resolve } from 'path' ;
3+ import process from 'process' ;
34import alias from '@rollup/plugin-alias' ;
45import commonjs from '@rollup/plugin-commonjs' ;
56import json from '@rollup/plugin-json' ;
6- import resolve from '@rollup/plugin-node-resolve' ;
7+ import { nodeResolve } from '@rollup/plugin-node-resolve' ;
78import typescript from '@rollup/plugin-typescript' ;
8- import { RollupOptions , WarningHandlerWithDefault } from 'rollup' ;
9+ import type { RollupOptions , WarningHandlerWithDefault } from 'rollup' ;
910import { string } from 'rollup-plugin-string' ;
1011import { terser } from 'rollup-plugin-terser' ;
1112import addCliEntry from './build-plugins/add-cli-entry' ;
@@ -14,7 +15,7 @@ import emitModulePackageFile from './build-plugins/emit-module-package-file';
1415import esmDynamicImport from './build-plugins/esm-dynamic-import' ;
1516import getLicenseHandler from './build-plugins/generate-license-file' ;
1617import replaceBrowserModules from './build-plugins/replace-browser-modules' ;
17- import pkg from './package.json' ;
18+ import { version } from './package.json' ;
1819
1920const commitHash = ( function ( ) {
2021 try {
@@ -24,15 +25,12 @@ const commitHash = (function () {
2425 }
2526} ) ( ) ;
2627
27- const now = new Date (
28- process . env . SOURCE_DATE_EPOCH
29- ? 1000 * parseInt ( process . env . SOURCE_DATE_EPOCH )
30- : new Date ( ) . getTime ( )
31- ) . toUTCString ( ) ;
28+ const { SOURCE_DATE_EPOCH } = process . env ;
29+ const now = new Date ( SOURCE_DATE_EPOCH ? 1000 * + SOURCE_DATE_EPOCH : Date . now ( ) ) . toUTCString ( ) ;
3230
3331const banner = `/*
3432 @license
35- Rollup.js v${ pkg . version }
33+ Rollup.js v${ version }
3634 ${ now } - commit ${ commitHash }
3735
3836 https://github.com/rollup/rollup
@@ -50,11 +48,11 @@ const onwarn: WarningHandlerWithDefault = warning => {
5048} ;
5149
5250const moduleAliases = {
53- entries : [
54- { find : 'help.md' , replacement : path . resolve ( 'cli/help.md' ) } ,
55- { find : 'package.json' , replacement : path . resolve ( 'package.json' ) } ,
56- { find : 'acorn' , replacement : path . resolve ( 'node_modules/acorn/dist/acorn.mjs' ) }
57- ] ,
51+ entries : {
52+ acorn : resolve ( 'node_modules/acorn/dist/acorn.mjs' ) ,
53+ 'help.md' : resolve ( 'cli/help.md' ) ,
54+ 'package.json' : resolve ( 'package.json' )
55+ } ,
5856 resolve : [ '.js' , '.json' , '.md' ]
5957} ;
6058
@@ -66,7 +64,7 @@ const treeshake = {
6664
6765const nodePlugins = [
6866 alias ( moduleAliases ) ,
69- resolve ( ) ,
67+ nodeResolve ( ) ,
7068 json ( ) ,
7169 conditionalFsEventsImport ( ) ,
7270 string ( { include : '**/*.md' } ) ,
@@ -80,24 +78,8 @@ const nodePlugins = [
8078export default ( command : Record < string , unknown > ) : RollupOptions | RollupOptions [ ] => {
8179 const { collectLicenses, writeLicense } = getLicenseHandler ( ) ;
8280 const commonJSBuild : RollupOptions = {
83- // fsevents is a dependency of chokidar that cannot be bundled as it contains binary code
84- external : [
85- 'buffer' ,
86- '@rollup/plugin-typescript' ,
87- 'assert' ,
88- 'crypto' ,
89- 'events' ,
90- 'fs' ,
91- 'fsevents' ,
92- 'module' ,
93- 'os' ,
94- 'path' ,
95- 'perf_hooks' ,
96- 'process' ,
97- 'stream' ,
98- 'url' ,
99- 'util'
100- ] ,
81+ // 'fsevents' is a dependency of 'chokidar' that cannot be bundled as it contains binary code
82+ external : [ 'fsevents' ] ,
10183 input : {
10284 'loadConfigFile.js' : 'cli/run/loadConfigFile.ts' ,
10385 'rollup.js' : 'src/node-entry.ts'
@@ -114,12 +96,7 @@ export default (command: Record<string, unknown>): RollupOptions | RollupOptions
11496 format : 'cjs' ,
11597 freeze : false ,
11698 generatedCode : 'es2015' ,
117- interop : id => {
118- if ( id === 'fsevents' ) {
119- return 'defaultOnly' ;
120- }
121- return 'default' ;
122- } ,
99+ interop : 'default' ,
123100 manualChunks : { rollup : [ 'src/node-entry.ts' ] } ,
124101 sourcemap : true
125102 } ,
@@ -160,7 +137,7 @@ export default (command: Record<string, unknown>): RollupOptions | RollupOptions
160137 plugins : [
161138 replaceBrowserModules ( ) ,
162139 alias ( moduleAliases ) ,
163- resolve ( { browser : true } ) ,
140+ nodeResolve ( { browser : true } ) ,
164141 json ( ) ,
165142 commonjs ( ) ,
166143 typescript ( ) ,
0 commit comments