1
1
import fs from 'fs'
2
2
import path from 'path'
3
+ import chalk from 'chalk'
3
4
import { resolveConfig , UserConfig , ResolvedConfig } from './config'
4
5
import Rollup , {
5
6
Plugin ,
@@ -13,7 +14,6 @@ import Rollup, {
13
14
} from 'rollup'
14
15
import { buildReporterPlugin } from './plugins/reporter'
15
16
import { buildDefinePlugin } from './plugins/define'
16
- import chalk from 'chalk'
17
17
import { buildHtmlPlugin } from './plugins/html'
18
18
import { buildEsbuildPlugin } from './plugins/esbuild'
19
19
import { terserPlugin } from './plugins/terser'
@@ -110,6 +110,10 @@ export interface BuildOptions {
110
110
* configurations that are suitable for distributing libraries.
111
111
*/
112
112
lib ?: LibraryOptions | false
113
+ /**
114
+ * @internal for now
115
+ */
116
+ ssr ?: boolean
113
117
}
114
118
115
119
export interface LibraryOptions {
@@ -137,6 +141,7 @@ export function resolveBuildOptions(
137
141
write : true ,
138
142
manifest : false ,
139
143
lib : false ,
144
+ ssr : false ,
140
145
...raw
141
146
}
142
147
@@ -344,10 +349,19 @@ export function onRollupWarning(
344
349
allowNodeBuiltins : string [ ] = [ ] ,
345
350
userOnWarn ?: WarningHandlerWithDefault
346
351
) {
352
+ function doWarn ( ) {
353
+ if ( userOnWarn ) {
354
+ userOnWarn ( warning , warn )
355
+ } else {
356
+ warn ( warning )
357
+ }
358
+ }
359
+
347
360
if ( warning . code === 'UNRESOLVED_IMPORT' ) {
348
361
let message : string
349
362
const id = warning . source
350
363
const importer = warning . importer
364
+
351
365
if ( id && isBuiltin ( id ) ) {
352
366
let importingDep
353
367
if ( importer ) {
@@ -377,6 +391,7 @@ export function onRollupWarning(
377
391
}
378
392
throw new Error ( message )
379
393
}
394
+
380
395
if (
381
396
warning . plugin === 'rollup-plugin-dynamic-import-variables' &&
382
397
dynamicImportWarningIgnoreList . some ( ( msg ) => warning . message . includes ( msg ) )
@@ -385,10 +400,6 @@ export function onRollupWarning(
385
400
}
386
401
387
402
if ( ! warningIgnoreList . includes ( warning . code ! ) ) {
388
- if ( userOnWarn ) {
389
- userOnWarn ( warning , warn )
390
- } else {
391
- warn ( warning )
392
- }
403
+ doWarn ( )
393
404
}
394
405
}
0 commit comments