Comments (5)
That's great, thanks for doing this. When I created LJS I decided not to use modules in order to keep things as simple as possible. Generally I have not used modules that much, can you tell me more about why you prefer to use them for something like this?
Would it be possible to to make the engine build system automatically spit out engine.all.module.js? Also, is the header actually necessary?
It seems like it just needs a footer with all the missing get/set functions and the export line. I can update engine.bat file to combine all and the footer and spit out engine.all.module.js in addition to the other files. Does that sound good?
from littlejs.
I love modules, and have found them good for a few reasons:
- Avoids polluting the global namespace. Import/export makes it very clear where dependencies are coming from when you open a file.
- Along those lines, since I usually use linting (ESLint extension) on my js files to check syntax, having no globals helps.
- No need to modify HTML <script> tags to bring in new modules; just import them in your js.
I anticipate the developer experience for LittleJS with ESM will be:
- Make a new project (
npm init
, add html and js files) - Run
npm i littlejsengine
- Use
import * as engine from 'littlejsengine';
(or some subset of methods, e.g.,import { engineInit } from 'littlejsengine';
) in their js. - Do some build process
Also, is the header actually necessary?
No. I thought there might be some use for it later on, but I guess not.
Does that sound good?
Yes! I made the changes and made a PR: #42 Let me know what you think.
from littlejs.
+1 to make LittleJS modules-friendly.
I'm using vite to build my stuff, and when it creates the release folder it skips adding the scripts that are not modules and modules not being used.
Of course you can manually add the files to the distribution build but it's something you don't want to do everytime.
I also use an app that makes it possible to use webpages as applications and it comes with a predefined set of commands that makes it impossible (I guess) to build the executable and add files manually right after.
So yeah +1 overall 🦊
from littlejs.
esm build now included! still needs work but this is a good path forward, thanks for your help and advice.
from littlejs.
Modules now fully supported and I added a demo that uses them!
https://killedbyapixel.github.io/LittleJS/examples/module/
from littlejs.
Related Issues (20)
- Vector2.normalize() returns (1,0) when used on a zero-length vector (0,0) HOT 1
- Docs: search dropdown shows wrong return types for some functions HOT 2
- bug: touchend event problem. HOT 3
- Programmatically Triggering Inputs in LittleJS for Adaptive Gaming HOT 3
- Use node for build system HOT 8
- Needs more tutorials
- Tilde (~) for debug mode HOT 3
- Unable to join discord HOT 5
- Documentation could be improved HOT 3
- Small error in tutorial HOT 2
- Pixel perfect on chrome HOT 1
- TileLayer rendered using WebGL or Canvas2D ?
- Improve tile indexing HOT 1
- VSCode intellisense HOT 3
- Upgrade to WebGL2 HOT 1
- isometric? HOT 2
- [ NPM ] Last build 1.7.11 failing HOT 1
- prevent popups on mobile HOT 2
- New LittleJS Logo HOT 5
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from littlejs.