question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

adding the type key "module" on the root will make threejs ESM-only

See original GitHub issue

Describe the bug

Hello! I was worried about this change of #23315 so I tested it and it validated my concern. By adding the type key on the root "type": "module" it will make threejs ESM-only and break all non-ESM libraries.

It should only be used in directories/user projects using ESM features such as test/package.json for example. Can we simply remove this line: "type": "module", or does the new paths ./ will break? @marcofugaro

Issue Analytics

  • State:closed
  • Created 2 years ago
  • Reactions:4
  • Comments:8 (5 by maintainers)

github_iconTop GitHub Comments

2reactions
Mugen87commented, Jan 25, 2022

I would say we give @marcofugaro’s solution a try and see how it works.

2reactions
marcofugarocommented, Jan 25, 2022

By adding the type key on the root “type”: “module” it will make threejs ESM-only and break all non-ESM libraries.

Not true, my attempt was to make three.js work both in esm and commonjs environment, according to the docs, I just forgot to provide a file with the .cjs extension.

Creating a new build output with the .cjs file fixes this.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Add .cjs build output needed for commonjs environments by ...
According to the docs one more thing is needed, an esm module must provide a .cjs file for commonjs environment. Added a short...
Read more >
Installation – three.js docs
Make sure to add { "type": "module" } to your package.json to enable ES6 modules in your node project.
Read more >
Importing Three.js as Module - Medium
Type npm init and press enter several times to accept the defaults. Type dir and there will be a new file in the...
Read more >
The Structure of a three.js App
We'll create this basic web page out of just two files: index.html, and styles/main.css. That's it. Open up the editor by pressing the...
Read more >
Three.js Fundamentals
A Scene in three.js is the root of a form of scene graph. Anything you want three.js to draw needs to be added...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found