Fix passthrough for dynamic import#4298
Conversation
|
I've imported this PR for testing and review. |
src/com/google/javascript/jscomp/deps/BrowserWithTransformedPrefixesModuleResolver.java
Show resolved
Hide resolved
|
@ChadKillingsworth, could you take a look at this PR and make sure it works for you, since you are likely to be impacted by these changes? |
There was a problem hiding this comment.
@brad4d I think this is a bug looking at how the other modules implement resolveJsModule. I'm assuming transformedAddress == null should really be loadAddress == null ? Earlier in this method a null pointer would have already been thrown if transformedAddress & a prefix replacement was defined too.
|
@brad4d I pushed a commit to help de-duplicate the copied logic. Hopefully this makes it clearer that resolveJsModuleSilently is effectively a copy each ModuleResolver's implementation, without the error. If you want me to rename the method, I'm happy to. I also pushed a change to where I assume the wrong value was being checked: |
|
I'm comfortable with the way the code looks now. |
|
Alas, stuff broke. |
|
@brad4d Thank you. It may be because I thought https://github.com/jdaugherty/closure-compiler/blob/5ebabe0e2b823c8f16223030380b691dad75309a/src/com/google/javascript/jscomp/deps/BrowserWithTransformedPrefixesModuleResolver.java#L150 was a bug - if it's not, I can revert that change. If you can help point me to what broke, I'm happy to help resolve these issues too. |
|
@brad4d It's been a long time since I've scrutinized this code, so its going to be hard for me to review this without spending a lot of time getting re-familiar with it. I am going to run this on my own project that makes heavy use of dynamic imports and see what happens. However - it looks like one of the tests is failing so I can't get a build artifact created to run that test. |
|
@ChadKillingsworth @brad4d Apologies, I thought the tests were working locally. Let me take another pass at this and see where my dedupe caused the cause. |
|
So the failing test ( I'm assuming that the right decision is to leave the fix in place (since that's how the other module resolvers work) and just ignore the LOAD_WARNING warning in the test. This is a behavior change though - before these errors were being swallowed / hidden. For the test itself, the module address @brad4d @ChadKillingsworth Should I revert that fix or should I update the test to ignoreWarnings(LOAD_WARNING)? |
|
The change being questioned is this one: jdaugherty@5ebabe0 |
|
It appears that quite a few things within Google depend on the apparent bug that ignores a failed module load here. So, the test failing within the closure-compiler repository when we "fix" it is the tip of the iceberg. I have:
I'm about to send this modification for internal testing. |
|
Thank you @brad4d , I'm here if I can help ... |
|
Good news! It looks like all the tests passed once I unfixed the "obvious bug". p.s. I suspect that the bug is hiding a case where we actually need the same "silent failure" behavior, but I'm not sure, and there's no need to fix it before merging this. |
Fixes #3941
@brad4d since you added a comment asking for help, I've created this PR. I took the approach you suggested - having a separate method that silently errors.