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

CommonJS breakage: many consumers still use dedent = require("dedent") #39

Closed
JoshuaKGoldberg opened this issue Jul 2, 2023 · 0 comments · Fixed by #40
Closed

CommonJS breakage: many consumers still use dedent = require("dedent") #39

JoshuaKGoldberg opened this issue Jul 2, 2023 · 0 comments · Fixed by #40
Assignees
Labels
status: accepting prs Please, send a pull request to resolve this! type: bug Something isn't working :(

Comments

@JoshuaKGoldberg
Copy link
Collaborator

JoshuaKGoldberg commented Jul 2, 2023

In the (old) current version 0.7.0, dedent is published with a dist/dedent.js that sets module.exports to the dedent function:

if (typeof module !== "undefined") {
  module.exports = dedent;
}

That's meant to be used with older-style Node.js code like:

const dedent = require("dedent");

However, in e13e334, the style was switched over to ES modules style default export:

exports.default = dedent;

This is a breaking change that just hasn't been published yet. Per this Sourcegraph query for const dedent = require("dedent"), many users are still using the old style API.

Since I'm trying to keep this package stable (#36), I'm going to use https://www.npmjs.com/package/babel-plugin-add-module-exports to dial back the breaking change. That way folks can import both with the old const dedent = require("dedent") and the new import dedent from "dedent" ways.

@JoshuaKGoldberg JoshuaKGoldberg added type: bug Something isn't working :( status: accepting prs Please, send a pull request to resolve this! labels Jul 2, 2023
@JoshuaKGoldberg JoshuaKGoldberg self-assigned this Jul 2, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
status: accepting prs Please, send a pull request to resolve this! type: bug Something isn't working :(
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant