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

Trailing slash breaks ESM compatibility #256

Closed
benmccann opened this issue Sep 29, 2022 · 2 comments
Closed

Trailing slash breaks ESM compatibility #256

benmccann opened this issue Sep 29, 2022 · 2 comments

Comments

@benmccann
Copy link

benmccann commented Sep 29, 2022

Originally reported in sveltejs/kit#7085

Loading this library in a project that uses Node.js ESM without bundling does not work:

Error [ERR_UNSUPPORTED_DIR_IMPORT]: Directory import 'node_modules/punycode/' is not supported resolving ES modules imported from build/server/chunks/_server.ts-7b9e82e7.js

I believe the error is coming from this line:

const punycode = require("punycode/");

Is there a reason to have that trailing slash or can it be removed?

@awaterma
Copy link
Member

I think the slash isn't required; I'll take a look at our package.json.

@wjhsf
Copy link
Contributor

wjhsf commented Jan 12, 2023

This change was introduced in #238 in order to enforce the use of the punycode npm package, rather than node's built-in. One possible resolution is to import the main export directly, require("punycode/punycode.js").

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants