Code Monkey home page Code Monkey logo

Comments (6)

jasonsturges avatar jasonsturges commented on May 22, 2024 3

@mendesbarreto Try version 2.0.3 - this removes the module type specifier.

Perhaps I'm missing something here, but I'd like to understand what's occurring in your environment. If you could share some details would help to trace this.

from lunarphase-js.

jasonsturges avatar jasonsturges commented on May 22, 2024 1

Ah, finally able to replicate this in a Node.js environment - I suppose that makes sense for Next.js

index.cjs.js is treated as an ES module file as it is a .js file whose nearest parent package.json contains "type": "module" which declares all .js files in that package scope as ES modules.

...although strangely I don't experience this issue in Next.js

This defeats the purpose of configuration, though:

  "main": "dist/index.cjs.js",
  "module": "dist/index.es.js",

Need to research how other packages are handling this.

from lunarphase-js.

jasonsturges avatar jasonsturges commented on May 22, 2024

Strangely I don't receive this in Next.js

image

from lunarphase-js.

jasonsturges avatar jasonsturges commented on May 22, 2024

Both TypeScript and JavaScript are functional in Next.js, with different targets.

Even before when I used Rollup directly, CommonJS has always been distributed as .js
image

Can you give some insights to your Next.js config, and TSConfig if you're using TypeScript?

Are you using this as import or require?

from lunarphase-js.

mendesbarreto avatar mendesbarreto commented on May 22, 2024

@jasonsturges It's working now, thank you so much for your help.

Now your questions:

Are you using this as import or require?

We are using import like:

import { Moon } from 'lunarphase-js';

It's quite odd because I've never encountered this issue with your library before. It only started happening after this recent change,

The command I am running is:

 NODE_ENV=production next build

Let me know any specific details about our project here you want to know.

from lunarphase-js.

jasonsturges avatar jasonsturges commented on May 22, 2024

@mendesbarreto Thanks for the information.

Some issue interpreting ES Modules vs Common JS... I'll continue to trace it, and hopefully will match a similar environment with the issue.

from lunarphase-js.

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.