mirror of
https://github.com/radareorg/quickjs.git
synced 2026-11-07 06:25:57 -10:00
Support for ES2020 arbitrary module namespace identifier names,
which allows using string literals as export/import names.
Examples:
```js
export { foo as "string-name" }
import { "string-name" as foo }
export * as "string-name" from "./mod.js"
```
26 lines
918 B
JavaScript
26 lines
918 B
JavaScript
// Test ES2020 string export/import names
|
|
import { assert } from "./assert.js";
|
|
import * as mod from "./fixture_string_exports.js";
|
|
|
|
// Test string import names
|
|
import { "string-export-1" as str1 } from "./fixture_string_exports.js";
|
|
import { "string-export-2" as str2 } from "./fixture_string_exports.js";
|
|
import { "string-name" as strMixed } from "./fixture_string_exports.js";
|
|
|
|
// Test regular imports still work
|
|
import { regularExport, normalName } from "./fixture_string_exports.js";
|
|
|
|
// Verify values
|
|
assert(str1, "value-1");
|
|
assert(str2, "value-2");
|
|
assert(strMixed, "mixed-value");
|
|
assert(regularExport, "regular");
|
|
assert(normalName, "mixed-value");
|
|
|
|
// Verify module namespace has string-named exports
|
|
assert(mod["string-export-1"], "value-1");
|
|
assert(mod["string-export-2"], "value-2");
|
|
assert(mod["string-name"], "mixed-value");
|
|
assert(mod.regularExport, "regular");
|
|
assert(mod.normalName, "mixed-value");
|