revolt.js
revolt.js copied to clipboard
bug: explicitly importing the ESM version fails
What happened?
When importing revolt.js' ESM version directly from revolt.js/lib/esm/index.js, an error is thrown because it's interpreted as a CJS module by both Node and Deno.
How to reproduce:
import { Client } from "revolt.js/lib/esm/index.js";
// or "npm:[email protected]/lib/esm/index.js" when using Deno
const bot = new Client();
Logs:
file:///home/jersey/projects/revolt-repro/index.js:1
import { Client } from "revolt.js/lib/esm/index.js";
^^^^^^
SyntaxError: Named export 'Client' not found. The requested module 'revolt.js/lib/esm/index.js' is a CommonJS module, which may not support all module.exports as named exports.
CommonJS modules can always be imported via the default export, for example using:
import pkg from 'revolt.js/lib/esm/index.js';
const { Client } = pkg;
at ModuleJob._instantiate (node:internal/modules/esm/module_job:123:21)
at async ModuleJob.run (node:internal/modules/esm/module_job:189:5)
Node.js v19.8.1
error: 'import', and 'export' cannot be used outside of module code at file:///home/jersey/projects/revolt-repro/node_modules/.deno/[email protected]/node_modules/revolt.js/lib/esm/index.js:1:1
export * from "./classes";
~~~~~~