Skip to content

Commit

Permalink
Add support for bundles with only a default entry point.
Browse files Browse the repository at this point in the history
Changes in `@yowasp/runtime` had made it possible to have bundles with
a single common entry point (wohoo!!), but before this commit, these
would fail to import. Fix this before releasing any such bundles.
  • Loading branch information
whitequark committed Jan 7, 2024
1 parent bc6a3b1 commit bae93fc
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 2 deletions.
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,10 @@

All notable changes to the YoWASP toolchain extension will be documented in this file.

## 0.2.4

- Updated the internal interface to the YoWASP runtime.

## 0.2.3

- Switched to an automated publishing workflow. All releases starting from this one are published from the continuous integration environment.
Expand Down
3 changes: 2 additions & 1 deletion src/extension.ts
Original file line number Diff line number Diff line change
Expand Up @@ -214,7 +214,8 @@ function workerEntryPoint(self: WorkerContext) {
Exit: CommandExitConstructor
};
try {
const entryPointURL = new URL(packageJSON["exports"]["browser"], url);
const entryPoint = packageJSON.exports.browser ?? packageJSON.exports.default;
const entryPointURL = new URL(entryPoint, url);
console.log(`[YoWASP toolchain] Importing bundle entry point from ${entryPointURL}`);
bundleNS = await self.importModule(entryPointURL);
} catch (e) {
Expand Down
2 changes: 1 addition & 1 deletion src/workerThread.ts
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,7 @@ if (USE_WEB_WORKERS) {
//
// Almost all of this can be deleted when VS Code ships Node v18.19.0 or later.
const globalThis: any = {
fetch: fetch,
importScripts: function() {
// Needs to be `TypeError` for Pyodide loader to switch to `await import`.
throw new TypeError(`importScripts() not implemented`);
Expand Down Expand Up @@ -120,7 +121,6 @@ if (USE_WEB_WORKERS) {
TextEncoder,
URL,
Blob,
fetch,
console,
performance,
crypto,
Expand Down

0 comments on commit bae93fc

Please sign in to comment.