Skip to content

Commit

Permalink
fix: don't resolve filtered files (#428)
Browse files Browse the repository at this point in the history
* 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
  • Loading branch information
agilgur5 committed Oct 3, 2022
1 parent 3ef3289 commit f6db596
Show file tree
Hide file tree
Showing 8 changed files with 30 additions and 26 deletions.
2 changes: 1 addition & 1 deletion dist/index.d.ts.map

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

9 changes: 5 additions & 4 deletions dist/rollup-plugin-typescript2.cjs.js
Expand Up @@ -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;
Expand Down Expand Up @@ -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,
Expand Down Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion dist/rollup-plugin-typescript2.cjs.js.map

Large diffs are not rendered by default.

9 changes: 5 additions & 4 deletions dist/rollup-plugin-typescript2.es.js
Expand Up @@ -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;
Expand Down Expand Up @@ -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,
Expand Down Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion dist/rollup-plugin-typescript2.es.js.map

Large diffs are not rendered by default.

18 changes: 9 additions & 9 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions package.json
@@ -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",
Expand Down Expand Up @@ -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"
Expand Down
10 changes: 6 additions & 4 deletions src/index.ts
Expand Up @@ -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;
Expand Down Expand Up @@ -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}'`);

Expand Down

0 comments on commit f6db596

Please sign in to comment.