Skip to content
This repository was archived by the owner on Nov 2, 2025. It is now read-only.

Conversation

@coreyfarrell
Copy link
Member

Top level await alters load ordering. For example if you have ./tap.js:

import './libtap-setup.js'
import t from 'libtap'

./libtap-setup.js:

import settings from 'libtap/settings'
import findUp from 'find-up'

const packageJSON = await findUp('package.json')
// read package.json and use it to alter settings

In this case tap.js was written to run the libtap-setup.js steps to completion before libtap is imported. Unfortunately having top level await in libtap-setup.js or anything it imports changes the order. libtap starts loading as soon as the first top level await is hit.

With this patch you would make two small changes. You would change import t from 'libtap' to import t from 'libtap/tla', then you would add a call to settings.markAsReady() after the settings changes are complete.

I'm not settled on this approach though it's the best I have right now.

@coreyfarrell coreyfarrell requested a review from isaacs February 23, 2021 21:22
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.

1 participant