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 b0e39228b639229ce29d5d8d0b4bd236e4b20852, 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
This commit is contained in:
Anton Gilgur 2022-10-03 15:24:16 -04:00 committed by GitHub
parent 3ef3289fc1
commit f6db59613a
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
8 changed files with 30 additions and 26 deletions

2
dist/index.d.ts.map vendored
View File

@ -1 +1 @@
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,UAAU,EAAoD,MAAM,QAAQ,CAAC;AAUtF,OAAO,EAAE,QAAQ,EAAE,MAAM,YAAY,CAAC;AAWtC,aAAK,WAAW,GAAG,OAAO,CAAC,QAAQ,CAAC,CAAC;AAErC,OAAO,EAAE,WAAW,EAAE,CAAA;AAEtB,QAAA,MAAM,UAAU,EAAE,UAAU,CAAC,WAAW,CA8YvC,CAAC;AAEF,eAAe,UAAU,CAAC"}
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,UAAU,EAAoD,MAAM,QAAQ,CAAC;AAUtF,OAAO,EAAE,QAAQ,EAAE,MAAM,YAAY,CAAC;AAWtC,aAAK,WAAW,GAAG,OAAO,CAAC,QAAQ,CAAC,CAAC;AAErC,OAAO,EAAE,WAAW,EAAE,CAAA;AAEtB,QAAA,MAAM,UAAU,EAAE,UAAU,CAAC,WAAW,CAgZvC,CAAC;AAEF,eAAe,UAAU,CAAC"}

View File

@ -27932,7 +27932,7 @@ catch (e) {
// these use globals during testing and are substituted by rollup-plugin-re during builds
const TS_VERSION_RANGE = (global === null || global === void 0 ? void 0 : global.rpt2__TS_VERSION_RANGE) || ">=2.4.0";
const ROLLUP_VERSION_RANGE = (global === null || global === void 0 ? void 0 : global.rpt2__ROLLUP_VERSION_RANGE) || ">=1.26.3";
const RPT2_VERSION = (global === null || global === void 0 ? void 0 : global.rpt2__ROLLUP_VERSION_RANGE) || "0.34.0";
const RPT2_VERSION = (global === null || global === void 0 ? void 0 : global.rpt2__ROLLUP_VERSION_RANGE) || "0.34.1";
const typescript = (options) => {
let watchMode = false;
let supportsThisLoad = false;
@ -27978,7 +27978,7 @@ const typescript = (options) => {
const buildDone = () => {
if (!watchMode && !noErrors)
context.info(safe.exports.yellow("there were errors or warnings."));
cache.done();
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
};
const pluginOptions = Object.assign({}, {
check: true,
@ -28065,10 +28065,11 @@ const typescript = (options) => {
const resolved = (_a = result.resolvedModule) === null || _a === void 0 ? void 0 : _a.resolvedFileName;
if (!resolved)
return;
if (filter(resolved))
cache.setDependency(resolved, importer);
if (resolved.endsWith(".d.ts"))
return;
if (!filter(resolved))
return;
cache.setDependency(resolved, importer);
context.debug(() => `${safe.exports.blue("resolving")} '${importee}' imported by '${importer}'`);
context.debug(() => ` to '${resolved}'`);
return require$$0$1.normalize(resolved); // use host OS separators to fix Windows issue: https://github.com/ezolenko/rollup-plugin-typescript2/pull/251

File diff suppressed because one or more lines are too long

View File

@ -27903,7 +27903,7 @@ catch (e) {
// these use globals during testing and are substituted by rollup-plugin-re during builds
const TS_VERSION_RANGE = (global === null || global === void 0 ? void 0 : global.rpt2__TS_VERSION_RANGE) || ">=2.4.0";
const ROLLUP_VERSION_RANGE = (global === null || global === void 0 ? void 0 : global.rpt2__ROLLUP_VERSION_RANGE) || ">=1.26.3";
const RPT2_VERSION = (global === null || global === void 0 ? void 0 : global.rpt2__ROLLUP_VERSION_RANGE) || "0.34.0";
const RPT2_VERSION = (global === null || global === void 0 ? void 0 : global.rpt2__ROLLUP_VERSION_RANGE) || "0.34.1";
const typescript = (options) => {
let watchMode = false;
let supportsThisLoad = false;
@ -27949,7 +27949,7 @@ const typescript = (options) => {
const buildDone = () => {
if (!watchMode && !noErrors)
context.info(safe.exports.yellow("there were errors or warnings."));
cache.done();
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
};
const pluginOptions = Object.assign({}, {
check: true,
@ -28036,10 +28036,11 @@ const typescript = (options) => {
const resolved = (_a = result.resolvedModule) === null || _a === void 0 ? void 0 : _a.resolvedFileName;
if (!resolved)
return;
if (filter(resolved))
cache.setDependency(resolved, importer);
if (resolved.endsWith(".d.ts"))
return;
if (!filter(resolved))
return;
cache.setDependency(resolved, importer);
context.debug(() => `${safe.exports.blue("resolving")} '${importee}' imported by '${importer}'`);
context.debug(() => ` to '${resolved}'`);
return normalize(resolved); // use host OS separators to fix Windows issue: https://github.com/ezolenko/rollup-plugin-typescript2/pull/251

File diff suppressed because one or more lines are too long

18
package-lock.json generated
View File

@ -1,12 +1,12 @@
{
"name": "rollup-plugin-typescript2",
"version": "0.34.0",
"version": "0.34.1",
"lockfileVersion": 2,
"requires": true,
"packages": {
"": {
"name": "rollup-plugin-typescript2",
"version": "0.34.0",
"version": "0.34.1",
"license": "MIT",
"dependencies": {
"@rollup/pluginutils": "^4.1.2",
@ -35,7 +35,7 @@
"rimraf": "3.0.2",
"rollup": "^2.70.2",
"rollup-plugin-re": "1.0.7",
"rollup-plugin-typescript2": "0.33.0",
"rollup-plugin-typescript2": "0.34.0",
"ts-jest": "^28.0.0",
"tslint": "6.1.3",
"typescript": "^4.6.3"
@ -5160,9 +5160,9 @@
}
},
"node_modules/rollup-plugin-typescript2": {
"version": "0.33.0",
"resolved": "https://registry.npmjs.org/rollup-plugin-typescript2/-/rollup-plugin-typescript2-0.33.0.tgz",
"integrity": "sha512-7ZXoZeX93kNb4/ICzOi2AlperVV6cAsNz8THqrbz+KNvpn47P2F/nFdK/BGhkoOsOwuYDuY57vccdZZrcd8/dA==",
"version": "0.34.0",
"resolved": "https://registry.npmjs.org/rollup-plugin-typescript2/-/rollup-plugin-typescript2-0.34.0.tgz",
"integrity": "sha512-dGtOz2kL6nQVgfIOmnA4Xh+5cFrs3bdu4jja/ej7WKR92RzOOixsn71LY5ZFFmKe1R677nUh+k2++NiY3un2PQ==",
"dev": true,
"dependencies": {
"@rollup/pluginutils": "^4.1.2",
@ -9601,9 +9601,9 @@
}
},
"rollup-plugin-typescript2": {
"version": "0.33.0",
"resolved": "https://registry.npmjs.org/rollup-plugin-typescript2/-/rollup-plugin-typescript2-0.33.0.tgz",
"integrity": "sha512-7ZXoZeX93kNb4/ICzOi2AlperVV6cAsNz8THqrbz+KNvpn47P2F/nFdK/BGhkoOsOwuYDuY57vccdZZrcd8/dA==",
"version": "0.34.0",
"resolved": "https://registry.npmjs.org/rollup-plugin-typescript2/-/rollup-plugin-typescript2-0.34.0.tgz",
"integrity": "sha512-dGtOz2kL6nQVgfIOmnA4Xh+5cFrs3bdu4jja/ej7WKR92RzOOixsn71LY5ZFFmKe1R677nUh+k2++NiY3un2PQ==",
"dev": true,
"requires": {
"@rollup/pluginutils": "^4.1.2",

View File

@ -1,6 +1,6 @@
{
"name": "rollup-plugin-typescript2",
"version": "0.34.0",
"version": "0.34.1",
"description": "Seamless integration between Rollup and TypeScript. Now with errors.",
"main": "dist/rollup-plugin-typescript2.cjs.js",
"module": "dist/rollup-plugin-typescript2.es.js",
@ -62,7 +62,7 @@
"rimraf": "3.0.2",
"rollup": "^2.70.2",
"rollup-plugin-re": "1.0.7",
"rollup-plugin-typescript2": "0.33.0",
"rollup-plugin-typescript2": "0.34.0",
"ts-jest": "^28.0.0",
"tslint": "6.1.3",
"typescript": "^4.6.3"

View File

@ -32,7 +32,7 @@ const typescript: PluginImpl<RPT2Options> = (options) =>
let generateRound = 0;
let rollupOptions: InputOptions;
let context: RollupContext;
let filter: any;
let filter: ReturnType<typeof createFilter>;
let parsedConfig: tsTypes.ParsedCommandLine;
let tsConfigPath: string | undefined;
let servicesHost: LanguageServiceHost;
@ -204,12 +204,14 @@ const typescript: PluginImpl<RPT2Options> = (options) =>
if (!resolved)
return;
if (filter(resolved))
cache.setDependency(resolved, importer);
if (resolved.endsWith(".d.ts"))
return;
if (!filter(resolved))
return;
cache.setDependency(resolved, importer);
context.debug(() => `${blue("resolving")} '${importee}' imported by '${importer}'`);
context.debug(() => ` to '${resolved}'`);