Coder Social home page Coder Social logo

Comments (9)

daniele-pelagatti avatar daniele-pelagatti commented on August 18, 2024 1

Ok, I kinda trust you but I wasn't able to reproduce the problem with a clean https://github.com/pmndrs/react-three-next initialization with the "untouched" library
image
and a yarn build produced no error
image
@CodyJasonBennett can you confirm this would fix the problem? or point me to a reproducibility procedure? I'm the kind of guy that likes to avoids "blind fixes" if possible

from gainmap-js.

daniele-pelagatti avatar daniele-pelagatti commented on August 18, 2024 1

v3.0.5 is out https://publint.dev/@monogrid/[email protected] seems fine, let me know if this solves this problem, thanks for the help!

from gainmap-js.

daniele-pelagatti avatar daniele-pelagatti commented on August 18, 2024

is this solved by adding something like this?

  "exports": {
    ".": {
      "import": "./dist/decode.js",
      "main":  "./dist/decode.umd.js", <----------
      "types": "./dist/decode.d.ts"
    },
    "./encode": {
      "import": "./dist/encode.js",
      "main":  "./dist/encode.umd.js", <----------      
      "types": "./dist/encode.d.ts"
    },
    "./libultrahdr": {
      "import": "./dist/libultrahdr.js",
      "main":  "./dist/libultrahdr.umd.js", <----------      
      "types": "./dist/libultrahdr.d.ts"
    },
    "./worker": {
      "import": "./dist/worker.js",
      "main":  "./dist/worker.umd.js", <----------            
      "types": "./dist/worker.d.ts"
    },
    "./worker-interface": {
      "import": "./dist/worker-interface.js",
      "main":  "./dist/worker-interface.umd.js", <----------                  
      "types": "./dist/worker-interface.d.ts"
    }
  },

I'm not sure what's the proper fix, I have no trouble bundling with vite

from gainmap-js.

daniele-pelagatti avatar daniele-pelagatti commented on August 18, 2024

or maybe I need to name the files .mjs

[...]
  "exports": {
    ".": {
      "import": "./dist/decode.mjs",
      [...]
    }
[...]

🤔
I'm trying to reproduce the problem with https://github.com/pmndrs/react-three-next

from gainmap-js.

drcmda avatar drcmda commented on August 18, 2024

good idea! i hope this is just a fluke. esm exports package.json is so complicated, i would not know how to even publish a package nowadays.

from gainmap-js.

CodyJasonBennett avatar CodyJasonBennett commented on August 18, 2024

See https://publint.dev/@monogrid/[email protected]. It should be (note the use of .cjs):

"main": "dist/decode.umd.cjs",
"module": "dist/decode.js",
"types": "dist/decode.d.ts",
"sideEffects": false,
"type": "module",
"exports": {
  ".": {
    "types": "./dist/decode.d.ts",
    "import": "./dist/decode.js",
    "default":  "./dist/decode.umd.cjs"
  },
  "./encode": {
    "types": "./dist/encode.d.ts",
    "import": "./dist/encode.js",
    "default":  "./dist/encode.umd.cjs"
  },
  "./libultrahdr": {
    "types": "./dist/libultrahdr.d.ts",
    "import": "./dist/libultrahdr.js",
    "default":  "./dist/libultrahdr.umd.cjs"
  },
  "./worker": {
    "types": "./dist/worker.d.ts",
    "import": "./dist/worker.js",
    "main":  "./dist/worker.umd.cjs"
  },
  "./worker-interface": {
    "types": "./dist/worker-interface.d.ts",
    "import": "./dist/worker-interface.js",
    "default":  "./dist/worker-interface.umd.js"
  }
},

from gainmap-js.

CodyJasonBennett avatar CodyJasonBennett commented on August 18, 2024

The reason this issue occurred was because Node tried to resolve your package from a CJS entrypoint (Next.js server-side), but the package only specifies the import condition (ESM-only). Since Node 14, it reads from the exports field over main when present (module is a Webpack-only field).

The use of .cjs or .mjs overrides the type key which controls which resolver Node should use for .js extensions. So, for an ESM package with "type": "module", you can use .cjs to specify a CJS entrypoint, and anything ending with .js is assumed to be ESM.

I couldn't clone this repository to implement this fix myself, but was referred here due to a downstream issue when resolving with Next.js, presumably through their app directory which uses a different compiler than our Next.js integration tests. https://publint.dev exists and can be used locally via CLI to ensure your package satisfies Node's increasingly complicated API contract.

from gainmap-js.

daniele-pelagatti avatar daniele-pelagatti commented on August 18, 2024

Okay then, I've opened #36 with the fix you proposed, will be merging soon

from gainmap-js.

daniele-pelagatti avatar daniele-pelagatti commented on August 18, 2024

I'm going to close this as no-one else reported a similar problem. If this problem resurfaces please feel free to open again, thanks everyone

from gainmap-js.

Related Issues (19)

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.