Skip to content
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

Handle ESM for helpers #146

Merged
merged 3 commits into from
Mar 14, 2018
Merged

Handle ESM for helpers #146

merged 3 commits into from
Mar 14, 2018

Conversation

JSteunou
Copy link
Contributor

@JSteunou JSteunou commented Mar 6, 2018

named export first, then default, then CJS

should resolve #145

named export first, then default, then CJS
@wswoodruff
Copy link
Contributor

Hi @JSteunou! Thanks for your contribution! Can you please add tests to cover those line changes to keep code coverage at 100%?

@JSteunou
Copy link
Contributor Author

JSteunou commented Mar 7, 2018

Sure but I might need some help for that

@wswoodruff
Copy link
Contributor

wswoodruff commented Mar 8, 2018

@JSteunou Sure! change one of these helpers to ESM and run npm test to make sure the code coverage goes to 100% https://github.com/hapijs/vision/tree/master/test/templates/valid/helpers

@wswoodruff
Copy link
Contributor

I was torn between adding a new test just for this feature or changing one of the existing helpers to ESM but it's really not worth a new test I think, unless someone else who works on this module thinks otherwise

@devinivy
Copy link
Member

devinivy commented Mar 8, 2018

How will you hit full code coverage without a new test (or two)?

@wswoodruff
Copy link
Contributor

All the helpers are being used and are CommonJS modules -- the new changes should be covered if one of them is changed to ESM

@devinivy
Copy link
Member

devinivy commented Mar 8, 2018

Ah, I see what you mean. There are a few cases here to hit,

const helper = required[name] || required.default || required;

@wswoodruff
Copy link
Contributor

wswoodruff commented Mar 8, 2018

Oh yeah! whoops =P
@JSteunou In order to hit 100% code coverage can you please add a dedicated test for ESM helpers?
You can use this test as a starting point to copy / paste / modify
https://github.com/hapijs/vision/blob/master/test/index.js#L589-L605

The helpers can do whatever you like, they can even just be copies of 'long' and 'uppercase', but exposed as ESM modules.

We'll need to cover the cases where one is exported as default, and the other is a named export

Checklist:

@JSteunou
Copy link
Contributor Author

JSteunou commented Mar 9, 2018

Sure, thanks for the hints, I'll try this asap

@JSteunou
Copy link
Contributor Author

JSteunou commented Mar 9, 2018

Ok I had to simulate ESModule behavior with CJS exports because I couldn't update the all test suite, but that should be enough :)

@wswoodruff
Copy link
Contributor

Hmmm I'm asking myself why are these weird global leaks happening all of a sudden causing tests to fail? The following leaks were detected:__core-js_shared__

This line in hapi-react-views seems to mitigate this issue by ignoring it on the lab test call, I don't know why it's happening rn tho.. https://github.com/jedireza/hapi-react-views/blob/master/package.json#L7

@JSteunou
Copy link
Contributor Author

New node 8.10 or related to what I added?

@wswoodruff
Copy link
Contributor

The only other issue I have is the tests aren't using ESM -- but I'm still considering merging it

@JSteunou
Copy link
Contributor Author

If you have a solution to use true ESM inside test I will take it ;)

@wswoodruff
Copy link
Contributor

After poking around, ESM in a test without babel looks like a nightmare -- no need to add anything more.

Thank you so much @JSteunou for your contribution!!

@wswoodruff wswoodruff merged commit 03a1d58 into hapijs:master Mar 14, 2018
@lock
Copy link

lock bot commented Jan 9, 2020

This thread has been automatically locked due to inactivity. Please open a new issue for related bugs or questions following the new issue template instructions.

@lock lock bot locked as resolved and limited conversation to collaborators Jan 9, 2020
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.

Should handle helpers as ES Module
3 participants