The examples/js directory will be removed with r148

Hi @Mugen87,

I understand the motivation of removing the js folder. There’s any plans to create a way to create UMD (Universe Module Definition) that takes jm folder as input. In my case, I’m still using script tag in my projects.

The use of “Rollup” module can transpile files to UMD as output (.umd.cjs extension)

Thanks

No sorry, there will be no official support for something like that. But it seems someone else already implement a converter: Demoduler

Thanks for your reply and the mention of moduler @Mugen87 !

This is a workaround but it could be interesting to have a way an to create build focused on examples folder (called as three.extra.* for example ) as many formats as three.js has like three.min.js, three.modules.js, three.cjs,etc

as per @MrBodean , I don’t think anyone can disagree es6 is best, though I suspect a lot of users here are not using three for large-scale applications, probably more one-offs/showcases/simplistic things. The reality is that if you do it the old way, it’s going to be a massive pain to change.

Does anyone have any good resources to educate me on what I would need to actually do to change old style into es6?

1 Like

maybe the easiest would be just write your own build command from /examples to your_controls_or_loader.min.js

1 Like

Thanks for your suggestion @makc3d . I think is the thing I will do. I agree that we have to adapt or tend code to current technologies but I have the following doubts for use ESM,

  1. I transpile my projects as .min.js through Clouse Compiler of Google that minimizes a lot all files of my projects. In the other hand modules can be transpiled in a single file using “Rollup” and, as far as I know, it generates the “module.js” as result of concatening all file modules in a single file.

  2. I have another doubt that I didn’t tried. If we create the transpiled “module.js” from 2 projects that it has same dependencies but diferent versions (defined in “package.json”)… Do they can coexist toghether ? If they can coexist toghether, we have also a same packages with diferent versions liveing toghether, is not optimized at all. It’s eating space and resources from my point of view.

Pavel, this looks like a job for Superman:

You can generate any module type you want with rollup. A minified UMD build setup looks like so: GitHub - Mugen87/three-jsm: Minimal three.js project setup using ES6 modules and rollup.

Check out the rollup_config.js for the actual build config.

well if we are using rollup, one could specify format: 'iife' and have their three.min.js the same way, no?