Skip to content

Commit

Permalink
Readme: fix "module-that-throws" example
Browse files Browse the repository at this point in the history
  • Loading branch information
nicolo-ribaudo committed Dec 9, 2024
1 parent c9b82dc commit d4d40fb
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -356,22 +356,22 @@ throw new Error("oops");
```
```js
// main1.js
import defer * as ns1 from 'module-that-throws';
import defer * as ns1 from 'module-that-throws1';
try { ns1.a } catch (e) { console.log('caught', e) } // logs "oops"
```

Module namespace objects of modules that are _already evaluated_ and threw during evaluation do now re-throw an error on
property access:
```js
// module-that-throws2
import * as ns2 from 'module-that-throws';
import * as ns2 from 'module-that-throws2';
globalThis.ns2 = ns2;
export let a = 1;
throw new Error("oops");
```
```js
// main2.js
import("module-that-throws").finally(() => {
import("module-that-throws2").finally(() => {
try { ns2.a } catch (e) { console.log('caught', e) } // Doesn't throw
});
```
Expand Down

0 comments on commit d4d40fb

Please sign in to comment.