Skip to content
This repository has been archived by the owner on May 23, 2022. It is now read-only.

Test with <script type=module> loader #4

Closed
wants to merge 1 commit into from
Closed

Test with <script type=module> loader #4

wants to merge 1 commit into from

Conversation

josh
Copy link
Owner

@josh 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
Copy link

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.

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