Closed reothues closed 1 year ago
import is being used in two contexts -- by rollup (after it gets transpiled into resolve call) -- this is run through the plugin chain. And also by typescript compiler when it parses the file that does the importing. This second run doesn't go through rollup plugin chain, so I don't think we can be compatible with plugins that rewrite imports...
Or did I get the problem wrong?
it's overwritten by rollup-plugin-typescript2 since it caches with ids without calling
this.resolve
first.
I'm not sure what you mean by "caches with ids" since rpt2's resolveId
implementation does not cache. It can also be filter
ed on as well.
If you mean Rollup's watch mode cache (the issue does not mention that), then your plugin may want to implement shouldTransformCachedModule
.
This plugin should implement that function as well, but it is a newer Rollup feature and so is still TODO.
return this.resolve(source, importer, { skipSelf: true, ...options, }).then(originalResolve
Looking at this code, you're explicitly saying to run other plugins first with this.resolve
, so you would expect that something may have gotten resolved by other plugins. If this plugin didn't do that and ran first in the chain, then it could resolve based on its own resolution first. Plugins are expected to resolve sequentially.
And also by typescript compiler when it parses the file that does the importing. This second run doesn't go through rollup plugin chain
As ezolenko mentions, given that this is TypeScript, the TypeScript compiler must also be able to resolve your imports. And really that's all that this plugin's resolveId
implementation does.
I'm not sure what your proposed solution is here and that would need some more details as well
Closing this as stale with no response from OP in a few months
Troubleshooting
The rollup-plugin has the ability to resolve an id into another:
: https://rollupjs.org/plugin-development/#resolveid thus
import from '/pathto/something.ts'
may have different outputs.like the example shown here, if you have some proxies inside
resolveId
, it's overwritten by rollup-plugin-typescript2 since it caches with ids without callingthis.resolve
first.Example: resolve SWITCH_ID to ENV_ID
transform ENV_ID and import from SWITCH_ID (the original one)