Code Monkey home page Code Monkey logo

Comments (8)

azu avatar azu commented on June 6, 2024

I've created minimal reproduce
https://github.com/azu/packemon-cjs-issue

from packemon.

milesj avatar milesj commented on June 6, 2024

@azu Thanks, this should fix it #136

On a side note, I suggest not using cjs/mjs in parallel as you run the risk of the dual package hazard. https://nodejs.org/api/packages.html#dual-commonjses-module-packages I suggest one or the other, preferably cjs as packemon will automatically create an mjs wrapper. https://packemon.dev/docs/features#automatic-mjs-wrappers-for-cjs-inputs

from packemon.

milesj avatar milesj commented on June 6, 2024

Published, let me know if there's still issues.

from packemon.

azu avatar azu commented on June 6, 2024

from packemon.

azu avatar azu commented on June 6, 2024

I want to treat my package as mjs package by default(type: module) because We may need to migrate Pure ESM in the future. I think that commonjs support is optional.
In other words, I want to treat .ts as mjs.

By contrast, index-wrapper.mjs force type: "commonjs". so it treat my pacakge as cjs package by default.

from packemon.

milesj avatar milesj commented on June 6, 2024

@azu How does the index-wrapper.mjs force it to CJS?

from packemon.

azu avatar azu commented on June 6, 2024

@milesj
Reproduce repo: https://github.com/azu/packemon-cjs-and-mjs-wrapper

Reproduce Steps:

  1. change type to "module" manually
  2. npm run build
  3. packemon will change type to "commonjs"
Aug-01-2022.07-21-05_optimized.mp4

from packemon.

milesj avatar milesj commented on June 6, 2024

@azu The type is set based on the chosen format: https://github.com/milesj/packemon/blob/master/packages/packemon/src/Package.ts#L475 And since the format is cjs, it sets it.

It shouldn't matter though since the wrapper will be used when importing from ESM because the import exports is set in exports.

from packemon.

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.