Giter Site home page Giter Site logo

Comments (8)

ruicsh avatar ruicsh commented on May 24, 2024

hi, 1.26 reverts back to having CommonJS as the default format, so everything should work as before.

btw, I'm cutting a new version (v2) where ESM will be the default format, and CommonJS a deep import

from dynoexpr.

ruicsh avatar ruicsh commented on May 24, 2024

actually if you're using node >= 13.10.0, you can use v2.4.0 and keep the code as is:

const dynoexpr = require('@tuplo/dynoexpr');

more details here: https://github.com/tuplo/dynoexpr#install

from dynoexpr.

cranberyxl avatar cranberyxl commented on May 24, 2024

While this approach now works for command-line node, it doesn't work for jest. What are the advantages of making this breaking change?

from dynoexpr.

ruicsh avatar ruicsh commented on May 24, 2024

you can still use v1.26.0, it works as before.

Having ESM export as default is where the ecosystem is going, other library makers have made that jump (ex: sindresorhus).

from dynoexpr.

ruicsh avatar ruicsh commented on May 24, 2024

for v1, it stays the same.

for v2, while Jest doesn't support ESM natively, you'll need to import the CJS version explicitly

const dynoexpr = require('@tuplo/dynoexpr/cjs');

I've added a Jest/CommonJS e2e test here https://github.com/tuplo/dynoexpr/blob/main/e2e/main-cjs.test.js

from dynoexpr.

cranberyxl avatar cranberyxl commented on May 24, 2024

I would have to change every place I import dynoexpr to use the deep import so jest works. I don't understand the value.

from dynoexpr.

ruicsh avatar ruicsh commented on May 24, 2024

I understand your frustration, but v1.x has no changes and will keep being supported until all kinks with ESM are fixed.

from dynoexpr.

ruicsh avatar ruicsh commented on May 24, 2024

@cranberyxl you can use a configuration on Jest to keep using require('@tuplo/dynoexpr') with v2.x (while Jest doesn't support ESM)

 {
   "jest": {
     "moduleNameMapper": {
       "dynoexpr$": "<rootDir>node_modules/@tuplo/dynoexpr/cjs"
    }
  }
}

from dynoexpr.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.