-
-
Notifications
You must be signed in to change notification settings - Fork 591
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Plugin Alias v3 throws error #203
Comments
I'm able to avoid this error with: plugins: [
customResolver,
alias({ entries: importAliases, customResolver })
] As a user, I may have expected |
@bennypowers It seems that your workaround is good, will shout if i run into anything. Thanks! |
It's not a workaround, because it just disables aliasing in a general case.
|
@pkit thanks for confirming. We're going to close citing that comment. If the example in the readme doesn't work for anyone else, please drop a comment here. |
Example from docs doesn't work. Workaround from #203 (comment) works, even if const nodeResolve = resolve()
plugins: [
alias({
entries: { ... },
customResolver: nodeResolve
}),
nodeResolve
] However, it feels more like a hack than a solution. |
Workaround doesn't work for any |
@vladshcherbin previous commenter indicates that's not so. unless someone can pinpoint why it's not working a positive assertion that it does work is going to take precedent. |
@pkit didn't test it with Anyway, this issue shouldn't be closed as it's clearly not working for many users following example from current docs. This is the reason we all came to this issue 😉 |
I'll reopen if someone can provide an updated reproduction. The repro provided on the original post doesn't run. |
@shellscape it's easy to pinpoint why it's not working: when placed after |
@pkit I'm not the author of Rollup or the alias plugin either. I'm a contributor and team member for maintaining the plugins. Because of the volume of issues we get here we just need reproductions so we don't spend time on trying to recreate the issues folks report. |
@shellscape cool, anyway. It seems like combination of plugins/packages/alias/src/index.ts Line 90 in ee5be6a
|
@shellscape here's reproduction - https://github.com/vladshcherbin/rollup-alias-error, latest alias version (3.1.0), docs example. Run with |
You know what, it looks like a |
@vladshcherbin it all comes to that issue again rollup/rollup#2826 |
https://repl.it/repls/AttachedWhimsicalDehardwarization Take a look in here, head into src/main.js and switch the two import lines to see the issue |
Thanks! |
Also reproduces when plugins: [
alias({
entries: [{
find: '@optimizely/optimizely-sdk',
customResolver: resolve({browser: false})
}]
}),
resolve({ browser: true })
] |
What needs to happen is that |
@lukastaegert that's a little outside of my wheelhouse. would you be able to POC that? I might be able to take it from there. |
Actually on second thought I think there might be a much simpler solution that would be inside Rollup and not require any plugin to change: We just make sure that |
Yup. That's what I did in the end. It also kind of ugly looking. But better. |
Ok, the problem is quite a different one than I thought, it is in a way what was already posted here: #203 (comment) At the moment, this only concerns the |
I can try to set up a PR. |
fix at #426 |
For the record, I resolved this problem once and for all by compiling aliases out-of-band using |
@bennypowers can you expand on that? What exactly was compiled? |
@pkit sure thing. This solution will only work for users writing typescript sources who are willing to run a wrapper around So my use case is to alias module like import '#components/card` instead of import '../../../card/card.ts I had been:
There were two downsides:
My ultimate solution was to use {
"compilerOptions": {
"plugins": [
{ "transform": "@zerollup/ts-transform-paths" }
]
} As well as doing a two-step build:
Those steps solved both the performance (builds down to 30-40 seconds) and maintenance (aliases handled exclusively by typescript) problems. |
@bennypowers cool. Thanks! |
How Do We Reproduce?
https://repl.it/repls/WatchfulUnsightlyStruct
Expected Behavior
Expect to compile as per v2.2.0
Actual Behavior
Throws mysterious error
(plugin alias) TypeError: Cannot read property 'input' of undefined
Thanks!
The text was updated successfully, but these errors were encountered: