Skip to content

Trailing slash breaks ESM compatibility #256

Closed

Description

@benmccann

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?

Activity

  1. awaterma commented on Nov 15, 2022

    @awaterma
    Member

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

  2. wjhsf commented on Jan 12, 2023

    @wjhsf
    Contributor

    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").

  3. added a commit that references this issue on Aug 27, 2023
    d77c0ef
  4. added a commit that references this issue on Feb 29, 2024
    997fda0
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions