-
Notifications
You must be signed in to change notification settings - Fork 1.7k
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
feat(config): add support for ES modules #2685
Conversation
@appsforartists can you check this change out and see if this works for you? I think this should be enough to support module loading. |
a811b70
to
8d3fa7e
Compare
lib/middleware/karma.js
Outdated
@@ -178,6 +178,7 @@ var createKarmaMiddleware = function ( | |||
var file = files.included[i] | |||
var filePath = file.path | |||
var fileExt = path.extname(filePath) | |||
var esModule = fileExt === '.js' && file.esModule |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
.endsWith('js')
might be better - there's talk of changing the extension to 'mjs'
0fe4f20
to
da2ef8d
Compare
This should have at least one e2e test, making sure this actually works as expected. |
Where would you recommend going about implementing a test for this? Is it the |
Yes, something like |
af6e64d
to
7cd386a
Compare
Question here - I don't believe PhantomJS supports ES modules, so how would such a test run in this scenario? It looks like we don't have Chrome available...is there a way we can use a modern browser for this test? |
Firefox should be always available |
9f4dd6b
to
6ce97e6
Compare
- Add support for ES modules via `esModule` property in file config object
@wesleycho I updated your test to ensure that it correctly tests that modules and relative imports work: |
On a more practical note, how would you use this today? Unless I miss something, you can't change |
I'm confused by your question - browsers support module loading via This PR is about adding support for loading scripts via this mechanism for browsers that support it based on the user's preferred setup. It will not work for browsers that do not support this, but for those situations, one should not have a karma config that sets this flag to |
My apologies, I should've try to be more clearer. To quote the article linked in #2684
For most browsers, this works only by setting an experimental flag. On a dev machine, this is definitively doable, but I have a hard time to understand how to make this works in a CI hence my question. Hope it's clearer. (and thanks for doing that work, it's definitely cool to be able to poke with this). |
Ah I see - so this is more about the future. When they move out of experimental, then they will be supported in truth. |
@wesleycho You gonna merge wesleycho#1? |
I'm running into this issue on a project I'm working on. Any chance this is going to be merged and released soon? |
@Florian-R FWIW, there are definitely options for enabling flags in a CI environment. It can be done in Karma (at least for Chrome) with a custom launcher. Many enterprises also control their browser configurations for internal users, so it's entirely possible that module loading via |
@wesleycho any update on this PR? |
What is the status of this PR? Es modules have better and better support and I would really like to use it for my tests since I can easily define my tests target browser. |
@dignifiedquire Looks like @wesleycho hasn't been on GitHub in a while. Wanna take this one over? I had fixed his tests in wesleycho#1, but doesn't look like he's seen that either. Would be nice if we merged both PRs. |
I am sadly not able to make any updates currently due to having switched jobs and needing approval from various parties before I am allowed to do any open source work again. If someone wants to take over for this, feel free! |
@wesleycho - can you please merge the PR I made to your PR, so we at least have a single artifact to take over? 😃 |
I can't do so - even that I am not allowed to do currently. It would be best to file a new PR to this project. |
OK, I'll make a new PR here. |
Moved to #2834. This issue can be closed now. Thanks for your help, @wesleycho. Sorry you can't finish it. 😢 |
Thanks for the effort, closing in favor of #2834 |
Fixed by #3072 |
esModule
property in file config objectThis should address #2684.