-
-
Notifications
You must be signed in to change notification settings - Fork 4k
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
Get rid of build step #5363
Comments
As appealing as having no build step is, it doesn't make sense to have it as a goal in and of itself. The real question becomes what would be gained by eliminating the build step? Modularization (of components) is something that can be achieved in numerous ways so I'd argue is orthogonal to the decision whether or not to get rid of the build step. Faster "builds" while developing A-Frame itself would be the most prominent benefit. Given the relatively small code base of A-Frame, the builds don't seem particularly slow (especially incremental builds) and there are probably ways to improve it still within the given build setup. It's worth noting that many users of A-Frame already have "no build step" setups, as they simply include the A-Frame bundle and are good to go. They stand little to gain and depending on how it's handled, might even have to do more to get things going, for example adding an import map + polyfill. Not saying this shouldn't be done, but I feel that there's more value in the modularization than the elimination of the build step. When done right it would enable tree-shaking and make it easier to integrate A-Frame with other frameworks and build tools. For backwards-compatibility a complete (synchronous) bundle can still be provided. |
Thanks for the feedback. No build is a step towards eliminating unnecessary tooling and complexity that makes programming less enjoyable. I agree that modularization and build step are separate goals with different benefits. Anyone is more than welcome to take a stab and modularization without adding extra tooling and complexity. I'm intrigued to see how it would look like. Main goal is always to make A-Frame and programming more fun 😀 |
I think you still need a minifier, non minified build is huge. If you want an unminified aframe without build step, first step would be to use ES6 modules, modify all the |
Would be nice to see how it looks like. My main concern about dev experience would be backwards compat with "non modularized" components or that one cannot longer just load a component via a simple script tag. |
Did some experimentation with replacing all For no build-step, there is another hurdle, some of the dependencies used aren't ESM. These include the As for compatibility, it's possible to still output a bundle that behaves the same, and can be crudely imported using import 'aframe'; // Full A-Frame setup
import 'third-party-esm-component';
import 'older-plain-component'; Or import 'aframe/base'; // Minimal
import 'aframe/components/hand-tracking-grab-controls';
// Pulls in it's own dependencies from aframe/...
import 'third-party-esm-component';
// Assumes certain dependencies to be present, so import them manually
import 'aframe/components/link';
import 'older-plain-component'; But this can all be incremental improved. As a first step the switch to ES6 modules can be made, while still retaining the same bundle outputs. From there steps can be taken towards 'no build', 'three-shaking', etc... |
Cool thanks. As soon as we can still keep an A-Frame build around that can load via a single script tag I'm good to explore |
When working on #5522 I saw that the tests are currently using |
In a webpack context, I am using for example: import "aframe/src/index.js";
import "aframe-extras/controls/index.js";
import { ParametricGeometry } from "three/addons/geometries/ParametricGeometry.js"; so that's easy to bundle my own three version and be sure to only have a single version of three loaded. To have that without a bundler, with an importmap that would be: <script type="importmap">
{
"imports": {
"aframe": "https://cdn.jsdelivr.net/npm/[email protected]/dist/aframe-master.module.min.js",
"three": "https://cdn.jsdelivr.net/npm/[email protected]/build/three.module.js",
"three/addons/": "https://cdn.jsdelivr.net/npm/[email protected]/examples/jsm/"
}
}
</script>
<script type="module">
import AFRAME from "aframe";
import * as THREE from "three";
import { ParametricGeometry } from "three/addons/geometries/ParametricGeometry.js";
</script> That's currently not possible, but it would be really nice to have that. So we keep a build step and also create |
exciting solution @vincentfretin |
Another thing to keep in mind, as of three r172, to use the webgpu render or tsl, you import That's the importmap used in webgpu examples https://threejs.org/examples/?q=webgpu <script type="importmap">
{
"imports": {
"three": "../build/three.webgpu.js",
"three/webgpu": "../build/three.webgpu.js",
"three/tsl": "../build/three.tsl.js",
"three/addons/": "./jsm/"
}
}
</script> and use WebGPURenderer instead of WebGLRenderer of course, not sure how we can switch aframe renderer to use one or the other if the three inclusion is handled by the user. |
Anyway first step is to replace all |
@vincentfretin I've dusted off my local branch, rebased it and fixed the unit tests. The result can be seen in this PR #5632 |
Awesome, I'll take a closer look soon at your work and do some experiments. |
It doesn't make sense to me to have no build in aframe repo, that would mean the user need to set themself in the importmap the other dependencies buffer, debug, deep-assign, load-bmfont, super-animejs, three-bmfont-text. That's not user friendly. And some dependencies are still cjs, so not feasible currently anyway. No build for creating an experience with an importmap with aframe, three and additional three/addons without the need to know how to create a cjs bundle of a three addon file just to be able to use it, that yes that's the use case we're looking for in my opinion. |
About WebGPURenderer, we could have a property on the renderer to select between webgl and webgpu renderer, but that would work only with importmap. <script type="importmap">
{
"imports": {
"three": "https://cdn.jsdelivr.net/npm/[email protected]/build/three.webgpu.js"
}
}
</script> THREE.WebGLRenderer is undefined, THREE.WebGPURenderer is defined. I did a quick test with replacing
I have no idea what's going on :D |
I made an example using aframe with importmap and using the teapot geometry from three/addons: |
awesome. WDYT so far @dmarcos ? |
The infinite loop was caused by some sort of algorithm conflict with the isNode check, my guess is because we set object3D.el that has isNode to true, renaming it to isAframeNode fixed the issue. |
Note that setFoveation was fixed in r173 it seems, I read that WebGPURenderer is now using the new XRManager. Only setPoseTarget is missing, it's a super-three patch. |
The post below made me consider it for the first time:
https://world.hey.com/dhh/you-can-t-get-faster-than-no-build-7a44131c
Has the time come to modularize components and get rid of the build step?
The text was updated successfully, but these errors were encountered: