Skip to content
Open
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 9 additions & 1 deletion src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -82,11 +82,14 @@ const typescript: PluginImpl<RPT2Options> = (options) =>
cache.done();
}

const hasTransformersOrSourceMapCallback = options?.sourceMapCallback || options?.transformers?.length;
const shouldEnableDefaultClean = !options?.extraCacheKeys && hasTransformersOrSourceMapCallback

const pluginOptions: IOptions = Object.assign({},
{
check: true,
verbosity: VerbosityLevel.Warning,
clean: false,
clean: shouldEnableDefaultClean,
cacheRoot: findCacheDir({ name: "rollup-plugin-typescript2" }),
include: ["*.ts+(|x)", "**/*.ts+(|x)"],
exclude: ["*.d.ts", "**/*.d.ts"],
Expand All @@ -99,6 +102,7 @@ const typescript: PluginImpl<RPT2Options> = (options) =>
tsconfigDefaults: {},
objectHashIgnoreUnknownHack: false,
cwd: process.cwd(),
extraCacheKeys: []
}, options as IOptions);

if (!pluginOptions.typescript) {
Expand Down Expand Up @@ -149,6 +153,10 @@ const typescript: PluginImpl<RPT2Options> = (options) =>
service = tsModule.createLanguageService(servicesHost, documentRegistry);
servicesHost.setLanguageService(service);

if(!pluginOptions.clean && shouldEnableDefaultClean) {
context.warn("You have enabled transformers or sourceMapCallback, but have disabled the default clean option. You may need to use 'extraCacheKeys' option to enable it again.")
}

cache = new TsCache(pluginOptions.clean, pluginOptions.objectHashIgnoreUnknownHack, servicesHost, pluginOptions.cacheRoot, parsedConfig.options, rollupOptions, parsedConfig.fileNames, context);

// reset transformedFiles Set on each watch cycle
Expand Down
1 change: 1 addition & 0 deletions src/ioptions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -30,4 +30,5 @@ export interface IOptions
tsconfigDefaults: any;
sourceMapCallback: (id: string, map: string) => void;
objectHashIgnoreUnknownHack: boolean;
extraCacheKeys: string[]
}
1 change: 1 addition & 0 deletions src/tscache.ts
Original file line number Diff line number Diff line change
Expand Up @@ -118,6 +118,7 @@ export class TsCache

if (noCache)
{
this.context.warn(yellow("Cleaning cache... If you want to use caching, please set `clean` option to false."));
this.clean();
return;
}
Expand Down