mirror of
https://github.com/gosticks/DefinitelyTyped.git
synced 2026-10-03 22:37:03 +00:00
transform/transformBundle can return null/undefined
I did not find it explicitly in documentation, but here is the code: https://github.com/rollup/rollup/blob/master/src/utils/transform.js#L78 https://github.com/rollup/rollup/blob/master/src/utils/transformBundle.js#L12
This commit is contained in:
Vendored
+2
-2
@@ -137,9 +137,9 @@ export interface Plugin {
|
||||
*/
|
||||
resolveId?(importee: string, importer: string | undefined): string | null | undefined | false | 0 | ''
|
||||
/** A module transformer function */
|
||||
transform?(this: TransformContext, source: string, id: string): string | { code: string, map: SourceMap }
|
||||
transform?(this: TransformContext, source: string, id: string): string | null | undefined | { code: string, map: SourceMap }
|
||||
/** A bundle transformer function */
|
||||
transformBundle?(source: string, options: { format: Format }): string | { code: string, map: SourceMap }
|
||||
transformBundle?(source: string, options: { format: Format }): string | null | undefined | { code: string, map: SourceMap }
|
||||
/** Function hook called when bundle.generate() is being executed. */
|
||||
ongenerate?(options: GenerateOptions, bundle: Bundle): void
|
||||
/** Function hook called when bundle.write() is being executed, after the file has been written to disk. */
|
||||
|
||||
@@ -14,12 +14,23 @@ const plugin: Plugin = {
|
||||
transform(source, id) {
|
||||
if (id === 'rxjs') {
|
||||
this.error(new Error(`Don't import this directly`))
|
||||
return null
|
||||
}
|
||||
const indexOfQuote = source.indexOf('"')
|
||||
if (indexOfQuote >= 0) {
|
||||
this.warn(`Prefer ' over " for strings`, indexOfQuote)
|
||||
return undefined
|
||||
}
|
||||
return source
|
||||
},
|
||||
transformBundle(source, options) {
|
||||
if (options.format === 'iife') {
|
||||
return `window.nonModule = true\n${source}`
|
||||
} else if (options.format === 'cjs') {
|
||||
return null
|
||||
}
|
||||
|
||||
return undefined
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user