Skip to content

Commit f6db596

Browse files
authored
fix: don't resolve filtered files (#428)
* fix: don't resolve `filter`ed files - if they're `exclude`d / not `include`d, then we shouldn't be processing them - we're already not transforming them, so this just applies the same exclusion to resolving - this is _partly_ a regression from b0e3922, as that removed the `allImportedFiles` Set that previously filtered out files not in the `tsconfig` `include` - but that _itself_ was a regression that was removed -- files that didn't pass `filter` should have _never_ been resolved - basically, the `allImportedFiles` regression was covering up this long-standing bug - also move `.d.ts` check to above the `filter` check - we shouldn't be adding declarations to the `cache`, in particular as we don't process declarations, so they'll never be marked as dirty - having this check above the `filter` should be slighltly more efficient as well (as would not having these files in the cache graph) types: be more specific with `filter`'s type - no need for this to be `any` * build - patch release has been waiting for a few weeks * pub: release v0.34.1 - patch bump with the past few fixes - bump internal rpt2 version to 0.34.0
1 parent 3ef3289 commit f6db596

8 files changed

+30
-26
lines changed

dist/index.d.ts.map

+1-1
Original file line numberDiff line numberDiff line change

dist/rollup-plugin-typescript2.cjs.js

+5-4
Original file line numberDiff line numberDiff line change
@@ -27932,7 +27932,7 @@ catch (e) {
2793227932
// these use globals during testing and are substituted by rollup-plugin-re during builds
2793327933
const TS_VERSION_RANGE = (global === null || global === void 0 ? void 0 : global.rpt2__TS_VERSION_RANGE) || ">=2.4.0";
2793427934
const ROLLUP_VERSION_RANGE = (global === null || global === void 0 ? void 0 : global.rpt2__ROLLUP_VERSION_RANGE) || ">=1.26.3";
27935-
const RPT2_VERSION = (global === null || global === void 0 ? void 0 : global.rpt2__ROLLUP_VERSION_RANGE) || "0.34.0";
27935+
const RPT2_VERSION = (global === null || global === void 0 ? void 0 : global.rpt2__ROLLUP_VERSION_RANGE) || "0.34.1";
2793627936
const typescript = (options) => {
2793727937
let watchMode = false;
2793827938
let supportsThisLoad = false;
@@ -27978,7 +27978,7 @@ const typescript = (options) => {
2797827978
const buildDone = () => {
2797927979
if (!watchMode && !noErrors)
2798027980
context.info(safe.exports.yellow("there were errors or warnings."));
27981-
cache.done();
27981+
cache === null || cache === void 0 ? void 0 : cache.done(); // if there's an initialization error in `buildStart`, such as a `tsconfig` error, the cache may not exist yet
2798227982
};
2798327983
const pluginOptions = Object.assign({}, {
2798427984
check: true,
@@ -28065,10 +28065,11 @@ const typescript = (options) => {
2806528065
const resolved = (_a = result.resolvedModule) === null || _a === void 0 ? void 0 : _a.resolvedFileName;
2806628066
if (!resolved)
2806728067
return;
28068-
if (filter(resolved))
28069-
cache.setDependency(resolved, importer);
2807028068
if (resolved.endsWith(".d.ts"))
2807128069
return;
28070+
if (!filter(resolved))
28071+
return;
28072+
cache.setDependency(resolved, importer);
2807228073
context.debug(() => `${safe.exports.blue("resolving")} '${importee}' imported by '${importer}'`);
2807328074
context.debug(() => ` to '${resolved}'`);
2807428075
return require$$0$1.normalize(resolved); // use host OS separators to fix Windows issue: https://github.com/ezolenko/rollup-plugin-typescript2/pull/251

dist/rollup-plugin-typescript2.cjs.js.map

+1-1
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

dist/rollup-plugin-typescript2.es.js

+5-4
Original file line numberDiff line numberDiff line change
@@ -27903,7 +27903,7 @@ catch (e) {
2790327903
// these use globals during testing and are substituted by rollup-plugin-re during builds
2790427904
const TS_VERSION_RANGE = (global === null || global === void 0 ? void 0 : global.rpt2__TS_VERSION_RANGE) || ">=2.4.0";
2790527905
const ROLLUP_VERSION_RANGE = (global === null || global === void 0 ? void 0 : global.rpt2__ROLLUP_VERSION_RANGE) || ">=1.26.3";
27906-
const RPT2_VERSION = (global === null || global === void 0 ? void 0 : global.rpt2__ROLLUP_VERSION_RANGE) || "0.34.0";
27906+
const RPT2_VERSION = (global === null || global === void 0 ? void 0 : global.rpt2__ROLLUP_VERSION_RANGE) || "0.34.1";
2790727907
const typescript = (options) => {
2790827908
let watchMode = false;
2790927909
let supportsThisLoad = false;
@@ -27949,7 +27949,7 @@ const typescript = (options) => {
2794927949
const buildDone = () => {
2795027950
if (!watchMode && !noErrors)
2795127951
context.info(safe.exports.yellow("there were errors or warnings."));
27952-
cache.done();
27952+
cache === null || cache === void 0 ? void 0 : cache.done(); // if there's an initialization error in `buildStart`, such as a `tsconfig` error, the cache may not exist yet
2795327953
};
2795427954
const pluginOptions = Object.assign({}, {
2795527955
check: true,
@@ -28036,10 +28036,11 @@ const typescript = (options) => {
2803628036
const resolved = (_a = result.resolvedModule) === null || _a === void 0 ? void 0 : _a.resolvedFileName;
2803728037
if (!resolved)
2803828038
return;
28039-
if (filter(resolved))
28040-
cache.setDependency(resolved, importer);
2804128039
if (resolved.endsWith(".d.ts"))
2804228040
return;
28041+
if (!filter(resolved))
28042+
return;
28043+
cache.setDependency(resolved, importer);
2804328044
context.debug(() => `${safe.exports.blue("resolving")} '${importee}' imported by '${importer}'`);
2804428045
context.debug(() => ` to '${resolved}'`);
2804528046
return normalize(resolved); // use host OS separators to fix Windows issue: https://github.com/ezolenko/rollup-plugin-typescript2/pull/251

dist/rollup-plugin-typescript2.es.js.map

+1-1
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package-lock.json

+9-9
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "rollup-plugin-typescript2",
3-
"version": "0.34.0",
3+
"version": "0.34.1",
44
"description": "Seamless integration between Rollup and TypeScript. Now with errors.",
55
"main": "dist/rollup-plugin-typescript2.cjs.js",
66
"module": "dist/rollup-plugin-typescript2.es.js",
@@ -62,7 +62,7 @@
6262
"rimraf": "3.0.2",
6363
"rollup": "^2.70.2",
6464
"rollup-plugin-re": "1.0.7",
65-
"rollup-plugin-typescript2": "0.33.0",
65+
"rollup-plugin-typescript2": "0.34.0",
6666
"ts-jest": "^28.0.0",
6767
"tslint": "6.1.3",
6868
"typescript": "^4.6.3"

src/index.ts

+6-4
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ const typescript: PluginImpl<RPT2Options> = (options) =>
3232
let generateRound = 0;
3333
let rollupOptions: InputOptions;
3434
let context: RollupContext;
35-
let filter: any;
35+
let filter: ReturnType<typeof createFilter>;
3636
let parsedConfig: tsTypes.ParsedCommandLine;
3737
let tsConfigPath: string | undefined;
3838
let servicesHost: LanguageServiceHost;
@@ -204,12 +204,14 @@ const typescript: PluginImpl<RPT2Options> = (options) =>
204204
if (!resolved)
205205
return;
206206

207-
if (filter(resolved))
208-
cache.setDependency(resolved, importer);
209-
210207
if (resolved.endsWith(".d.ts"))
211208
return;
212209

210+
if (!filter(resolved))
211+
return;
212+
213+
cache.setDependency(resolved, importer);
214+
213215
context.debug(() => `${blue("resolving")} '${importee}' imported by '${importer}'`);
214216
context.debug(() => ` to '${resolved}'`);
215217

0 commit comments

Comments
 (0)