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

[Limbo] Sort out the bundling process #1142

Closed
L1lith opened this issue Oct 4, 2022 · 7 comments
Closed

[Limbo] Sort out the bundling process #1142

L1lith opened this issue Oct 4, 2022 · 7 comments

Comments

@L1lith
Copy link
Contributor

L1lith commented Oct 4, 2022

I was thinking it would be best to ship the full source code that way it can be imported directly without needing to load the whole thing. There might need to be a legacy bundle

Also it relates to this issue as we need to orient the tests around our distributions.

It would also make sense to make a special browser dist where the dependencies point to CDN URLs instead of using NPM package names, that way it can be imported directly in the browser without a bundling step (which would also eliminate the need for tree-shaking all-together when being used this way). We could put this distribution on a CDN too (or put a download on the website or both). We could also look for alternative ways to make a browser distro where the dependencies are included inside without requiring bundling the whole lib into one file

@obiot
Copy link
Member

obiot commented Oct 10, 2022

done, the build process willl now generate a melonjs.mjs tree-shakeable build, which is actually a folder with all separate chunk, that includes all required transforms and external dependencies.

I propose to keep the previous/existing melonjs.module.js for backward compatibility, but then slowly transition to melonjs.mjs in our source code.

@L1lith
Copy link
Contributor Author

L1lith commented Oct 15, 2022

@obiot should we re-open this?

@obiot obiot reopened this Oct 16, 2022
@obiot
Copy link
Member

obiot commented Oct 16, 2022

yes maybe, I've been working these last 2 days on a bug in the collision system (see here), as soon I'm done wit it, I'll resume the build process update, now that also rollup 3 has been released

@obiot
Copy link
Member

obiot commented Oct 25, 2022

@L1lith finally moved to rollup 3, but it was not that straightforward, and I also had to upgrade to node 19 and add some other workarounds :)

I haven't yet (re)added the tree-shaking module, I'll look at it tomorrow, but that will be the last step !

@obiot
Copy link
Member

obiot commented Oct 26, 2022

@L1lith and we are done I think here !

I kept dist/melonjs.module.js as the main entry in package.json, but then changed the module one to dist/melonjs.mjs/index.js. Module is the one commonly used by bundler, so this should enable tree-shaking automatically (I'll have to try with the boilerplate and webpack).

Maybe we can rename melonjs.mjs to melon.mjs, but else if you have no comments, and happy about it we can close this one !

@obiot
Copy link
Member

obiot commented Oct 26, 2022

adding this one here for reference: https://nodejs.org/api/packages.html#nodejs-packagejson-field-definitions

@obiot
Copy link
Member

obiot commented Oct 27, 2022

@L1lith closing this one

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

No branches or pull requests

2 participants