Skip to content

Commit cf37250

Browse files
committed
Bump package version to 1.0.6
1 parent 623689f commit cf37250

File tree

3 files changed

+19
-14
lines changed

3 files changed

+19
-14
lines changed

CHANGELOG.md

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,18 @@
11
# Changelog
22

3+
## 1.0.6
4+
5+
- native: Fix reexport output
36

47
## 1.0.5
58

69
- lexer: Support reexport extends
710
```js
8-
var foo = require("foo");
9-
foo.bar = true;
10-
module.exports = foo;
11-
// outputed named exports: [ "bar", ...(foo.namedExports) ]
11+
var lib = require("lib");
12+
lib.bar = true;
13+
module.exports = lib;
14+
// output:
15+
// { exports: [ "bar" ], reexports: [ "lib" ] }
1216
```
1317
- lexer: Support `var foo = exports; foo.bar = true` pattern
1418
- lexer: Support `var foo = exports.foo = ...` pattern

wasm/index.mjs

Lines changed: 10 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,21 @@
11
import { initSync, parse as __wbg_parse } from "./pkg/cjs-module-lexer.js";
2-
const wasmPath = "./pkg/cjs-module-lexer_bg.wasm";
32

43
let wasm;
4+
const wasmPath = "./pkg/cjs-module-lexer_bg.wasm";
5+
const wasmUrl = new URL(wasmPath, import.meta.url);
6+
57
if (globalThis.process || globalThis.Deno || globalThis.Bun) {
68
const { readFileSync } = await import("node:fs");
7-
const url = new URL(wasmPath, import.meta.url);
8-
const wasmData = readFileSync(url.pathname);
9+
const wasmData = readFileSync(wasmUrl.pathname);
910
wasm = await WebAssembly.compile(wasmData);
1011
} else {
11-
const url = new URL(wasmPath, import.meta.url);
1212
const pkgPrefix = "/@esm.sh/cjs-module-lexer@";
13-
if (url.pathname.startsWith(pkgPrefix)) {
14-
const version = url.pathname.slice(pkgPrefix.length).split("/", 1)[0];
15-
url.pathname = pkgPrefix + version + wasmPath.slice(1);
13+
if (wasmUrl.pathname.startsWith(pkgPrefix)) {
14+
// fix the wasm url for esm.sh usage
15+
const version = wasmUrl.pathname.slice(pkgPrefix.length).split("/", 1)[0];
16+
wasmUrl.pathname = pkgPrefix + version + wasmPath.slice(1);
1617
}
17-
const res = await fetch(url);
18+
const res = await fetch(wasmUrl);
1819
if (!res.ok) {
1920
throw new Error(`failed to fetch wasm: ${res.statusText}`);
2021
}
@@ -24,7 +25,7 @@ if (globalThis.process || globalThis.Deno || globalThis.Bun) {
2425
initSync({ module: wasm });
2526

2627
/**
27-
* parse the given code and return the exports and reexports
28+
* parse the given cjs module and return the name exports and reexports
2829
* @param {string} filename
2930
* @param {string} code
3031
* @param {{ nodeEnv?: 'development' | 'production', callMode?: boolean }} options

wasm/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
{
22
"name": "@esm.sh/cjs-module-lexer",
33
"description": "A lexer for detecting the `module.exports` of a CJS module.",
4-
"version": "1.0.5",
4+
"version": "1.0.6",
55
"type": "module",
66
"main": "index.mjs",
77
"scripts": {

0 commit comments

Comments
 (0)