Skip to content
This repository has been archived by the owner on Aug 4, 2021. It is now read-only.

Fix #337 Keep isCjsPromises between commonjs() calls #338

Merged
merged 1 commit into from Aug 9, 2018

Conversation

porsager
Copy link
Contributor

@porsager porsager commented Aug 9, 2018

When using rollup cache, rollup won't call transform if it has a cache, so it appears the promise will never resolve because isCjsPromises is cleared between calls to commonjs().

I had to change the tests overall a bit to ensure they ran as if commonjs was loaded anew every time. I'm not sure it's the best way to do it though, but since there wasn't any state saved between runs until now it should be ok.

@@ -37,6 +37,7 @@ function startsWith ( str, prefix ) {
return str.slice( 0, prefix.length ) === prefix;
}

const isCjsPromises = Object.create(null);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

My worry is this could be cache poisoning if this changes between runs (eg a file changes from ESM to CJS or vice versa).

Do you know what the root cause was on the stalling that this fixes it?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think it's because rollup won't call transform again for paths where code hasn't changed, so .resolve will never be called. I'm unfortunately not familiar with the flow, but yes, I'm sure there's a better way.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ah thanks that makes complete sense to understand the cause.

@guybedford
Copy link
Contributor

The new cache work happening in core will actually resolve this issue.

So I would suggest we merge this even though it isn't quite correct, as it will be able to be corrected soon enough (once rollup/rollup#2389 lands).

@guybedford guybedford merged commit 441e927 into rollup:master Aug 9, 2018
@wearhere
Copy link

@guybedford doesn't look this has been published to npm yet, can you do so?

@guybedford
Copy link
Contributor

Sure, unfortunately I don't have publishing rights to this one. //cc @lukastaegert

@TrySound
Copy link
Member

@guybedford I just invited you.

@lukastaegert
Copy link
Member

published

@wearhere
Copy link

Thanks for the quick turnaround!

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

5 participants