Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Exclude three.js from build #11

Merged
merged 1 commit into from
Mar 10, 2022
Merged

Exclude three.js from build #11

merged 1 commit into from
Mar 10, 2022

Conversation

stefnotch
Copy link
Contributor

I just noticed that I forgot to exclude three.js from the built output. This made it significantly larger than it should have been.
This fixes that by marking three.js as an external dependency. And it moves it to peerDependencies.

However, it introduces a new problem. The built file now starts with the following, since it's

  1. a module
  2. uses Raycaster and Vector2 from three.js
  3. doesn't know how to import three.js
import{Raycaster as a,Vector2 as h}from"three";

In Node.js or with any modern build tool, this works quite fine. "three" is specified in the package.json, and thus, Node/the build tool knows what to do and where to find it (node_modules).

However, web browsers don't. This effectively breaks the examples, since the examples don't go through a compile step.

There is a really nice proposal called "import maps", which solves that. It lets you specify what dependencies there are and how to get them. And Chrome already supports them. But other browsers aren't quite that far yet.

And move it to peerDependencies
@markuslerner markuslerner merged commit 0c395f9 into markuslerner:master Mar 10, 2022
@markuslerner
Copy link
Owner

Hi @stefnotch,

thank you for making this change!

I fixed the examples using import maps and a polyfill for import maps. The three.js examples also do it like that. I also created a new release v1.3.0.

I hope this also fixes issues #10 and #12.

@stefnotch
Copy link
Contributor Author

Sweet 👍
I didn't know that it was possible to polyfill import maps. That's nice indeed!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants