-
Notifications
You must be signed in to change notification settings - Fork 116
Build halts prematurely with no error for incorrectly configured build #341
Comments
Had this problem a few times. Really frustrating. Thanks for the repro. |
I've been digging into this a tiny bit. As far as I can tell it falls down to the following:
I believe the potential fix for this is the following: diff --git src/index.js src/index.js
index 64a3991..16c23ed 100644
--- src/index.js
+++ src/index.js
@@ -205,7 +205,7 @@ export default function commonjs ( options = {} ) {
},
transform ( code, id ) {
- if ( !filter( id ) ) return null;
+ if ( !filter( id ) && !isCjsPromises[id] ) return null;
if ( extensions.indexOf( extname( id ) ) === -1 ) return null;
const transformPromise = entryModuleIdsPromise.then( (entryModuleIds) => {
The problem with this fix is that it means the diff --git src/index.js src/index.js
index 64a3991..1ec818d 100644
--- src/index.js
+++ src/index.js
@@ -205,7 +205,10 @@ export default function commonjs ( options = {} ) {
},
transform ( code, id ) {
- if ( !filter( id ) ) return null;
+ if ( !filter( id ) ) {
+ setIsCjsPromise(id, null)
+ return null;
+ }
if ( extensions.indexOf( extname( id ) ) === -1 ) return null;
const transformPromise = entryModuleIdsPromise.then( (entryModuleIds) => {
The above means the build completes but of course
@lukastaegert what are your thoughts about this? I'm happy to make a PR but I'm not sure either of these is ideal. |
Please hold off on PRs as I started refactoring a lot of things in #331 and I would not want to merge this yet. Or rather, you could make a PR vs. #331. Digging through the code myself for the past few days, this is what I know so far myself:
Cf. rollup-plugin-commonjs/src/transform.js Line 311 in d449220
I tried but I could not think of a better solution for this general problem yet. The big problem about the isCjsPromise situation is that there is no hard connection between the code setting the Promises and the code reading the Promises i.e. there are no guarantees Promises are always resolved. Will think about this a little more tomorrow, would be good if there is a way to establish such a connection. Ideally, requesting a Promise would trigger a transform but I am not sure how this could be done. |
Ok, I back-pedalled on #331 as it was just getting too large, so I think I will go for one of the interim solutions above so far. As a long term solution, I currently think the best would be to implement a new function on the plugin context, something like This function could then be called from within the
This would help to resolve quite a few potential discrepancies. But I think this is future talk for now. |
Here's a repro repo. Run
npm run broken
to see the broken behavior, andnpm run working
for the behavior when we have the correct config.We have two modules
a
andb
.a
is acommonjs
module.a
uses functionality exposed byb
.a
resolvesb
using some other plugin (i.e. not by a relativerequire
).a
is included in thecommonjs.include
config, butb
is not.b
can be acommonjs
module or an es native module.Expected behavior: we get an error.
Actual behavior: no error, exit code
0
.This is super distilled from the original problem I had, which also involved
rollup-plugin-node-resolve
androllup-plugin-alias
, but this seems to be exclusively a problem with thecommonjs
plugin.The text was updated successfully, but these errors were encountered: