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鈥檒l occasionally send you account related emails.

Already on GitHub? Sign in to your account

Test with <script type=module> loader #4

Closed
wants to merge 1 commit into
base: master
from

Conversation

2 participants
@josh
Owner

josh commented Oct 10, 2017

Looking into a way the test suite for this repository could use <script type=module> as it would likely work in the future without any build tools or extra module loading support. With the help of a Service Worker shim that could be deleted in the future, these tests can be ran in Chrome today.

Well I'd really like to have a simple test harness like this, theres still a bunch of hurdles today to deal with. So this probably isn't something that should be merged.

  • <script type=module> works today in Chrome and Safari! 馃帀 this part has come along way.
  • Unfortunately custom module identifier resolves aren't implement nor spec'd out. Browsers have no way of handling import 'selector-set' today. This can be worked around with Service Workers. I think this could be a useful SW script to publish that rewrites import resolves into node_modules/ paths. But this still depends on SW, so even though Safari has come so far, it means we can't test there yet.
  • selector-set is the only runtime dependency here which publishes a jsnext main. That's great, but most npm packages aren't doing this yet.
  • Mocha and Chai aren't module friendly yet. Chai uses some magic to write its CJS exports which isn't super friendly to tools ES export scanning tools which expect exported functions to be declared statically. Ideally import {assert} from 'chai' could work here. Similar issue with mocha, its expected to be installed in the global environment.
  • Karma has its own entirely different mocha loading system which is also incompatible with modules.

CC: @mislav @keithamus @dgraham @koddsson @muan

@koddsson

This comment has been minimized.

Show comment
Hide comment
@koddsson

koddsson Oct 11, 2017

Shame that safari hasn't implemented the service worker 馃槶 For what it's worth you can test this in firefox too by enabling the dom.moduleScripts.enabled flag in about:config.

koddsson commented Oct 11, 2017

Shame that safari hasn't implemented the service worker 馃槶 For what it's worth you can test this in firefox too by enabling the dom.moduleScripts.enabled flag in about:config.

@josh josh closed this Oct 13, 2017

@josh josh deleted the esm-test branch Oct 13, 2017

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment