1
0
Fork 0
mirror of https://github.com/denoland/deno.git synced 2024-12-12 10:37:52 -05:00
denoland-deno/tests/specs/npm/lossy_utf8_script_from_cjs/main.mjs
Luca Casonato c1f23c5788
fix(ext/node): lossy UTF-8 read node_modules files (#24140)
Previously various reads of files in `node_modules` would error on
invalid UTF-8. These were cases involving:

- reading package.json from Rust
- reading package.json from JS
- reading CommonJS files from JS
- reading CommonJS files from Rust (for ESM translation)
- reading ESM files from Rust
2024-06-08 18:36:13 +02:00

10 lines
290 B
JavaScript

import { createRequire } from "node:module";
// Import this so that deno_graph knows to download this file.
if (false) import("npm:@denotest/lossy-utf8-script@1.0.0");
const require = createRequire(import.meta.url);
const mod = require("@denotest/lossy-utf8-script");
console.log(mod);