Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

bug: explicitly importing the ESM version fails #83

Closed
williamhorning opened this issue Jul 2, 2023 · 0 comments · Fixed by #84
Closed

bug: explicitly importing the ESM version fails #83

williamhorning opened this issue Jul 2, 2023 · 0 comments · Fixed by #84
Labels
bug Something isn't working

Comments

@williamhorning
Copy link
Contributor

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:revolt.js@7.0.0-beta.7/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/revolt.js@7.0.0-beta.9/node_modules/revolt.js/lib/esm/index.js:1:1

  export * from "./classes";
  ~~~~~~
@williamhorning williamhorning added the bug Something isn't working label Jul 2, 2023
This was referenced Jul 9, 2023
@insertish insertish moved this to 💡 Open in Revolt Project Mar 28, 2024
@github-project-automation github-project-automation bot moved this from 💡 Open to ✅ Done in Revolt Project Jun 8, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
Archived in project
Development

Successfully merging a pull request may close this issue.

1 participant