fix: don't skip resolving files imported by other plugins#365
Merged
ezolenko merged 1 commit intoezolenko:masterfrom Jun 24, 2022
Merged
fix: don't skip resolving files imported by other plugins#365ezolenko merged 1 commit intoezolenko:masterfrom
ezolenko merged 1 commit intoezolenko:masterfrom
Conversation
- previously the `allImportedFiles` Set was _basically_ used to skip any files that were imported by other plugins
- it only filtered out on `importer` (not `importee`)
- this is a bit of a problem though, as other plugins that create JS code, or `allowJs` JS code, or heck, even regular JS code that Rollup processes without plugins, may actually import TS files
- and Rollup's plugin system is designed to handle that scenario, so rpt2 actually _should_ resolve those files
- notably, rpt2 already _transforms_ those files, it just didn't resolve them
- which is why using `@rollup/plugin-node-resolve` with a `.ts` extension solved this as a workaround
- the file would be resolved by `node-resolve` then actually transformed by rpt2
- but rpt2 should resolve TS files itself, `node-resolve` shouldn't be necessary
- this caused the issue that extensionless imports from such files wouldn't get resolved to TS files and may cause Rollup to error
- in particular, this popped up with extensionless imports of TS files from Svelte files
- `resolveId` is actually the last remaining place where `allImportedFiles` was used
- so after removing it from here, we can just remove it entirely
- which should be a small optimization
- for reference:
- `allImportedFiles` would be any `include`d files as well as TS files that have been transformed (at this point in the build) and their references
- this is a pretty gigantic list as is, so I'm actually not sure that removing this is actually that big of a de-opt
- and it only affects mixed TS / non-TS codebases too
- this seems to have been added in b0a0ecb, but that commit doesn't actually seem to fix the issue it references
- see my root cause analyses in the issues
This was referenced Jun 23, 2022
This was referenced Sep 26, 2022
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Resolve files imported from non-TS files / other plugins / JS files, such as TS files imported by Svelte files
Could not resolveTS files without extension (.ts) from Svelte files #283Details
previously the
allImportedFilesSet was basically used to skip any files that were imported by other pluginsimporter(notimportee)allowJsJS code, or heck, even regular JS code that Rollup processes without plugins, may actually import TS files@rollup/plugin-node-resolvewith a.tsextension solved this as a workaroundnode-resolvethen actually transformed by rpt2node-resolveshouldn't be necessaryCould not resolveTS files without extension (.ts) from Svelte files #283resolveIdis actually the last remaining place whereallImportedFileswas usedfor reference,
allImportedFileswould be anyincluded files as well as TS files that have been transformed (at this point in the build) and their referencesHistorical Context
include/excludewhen generating declarations #162filter"missed" declarations as well #347 (comment) and Rollup errorCould not resolveTS files without extension (.ts) from Svelte files #283 (comment) and my next comments after both of those