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

Output treeshakeable module builds #4601

Merged
merged 6 commits into from
Sep 1, 2022
Merged

Conversation

slimbuck
Copy link
Member

This PR changes the engine es6/esm module output to preserve modules. This results in a hierarchy of files for es6 target, one module for each interface exported by index.js (the rest is not treeshakable and is placed directly into index.js).

Preserving modules will allow applications to treeshake the engine source.

We also remove the header comment from the minified build, otherwise it becomes bloated with comments (since each individual module gets it).

@slimbuck slimbuck requested a review from a team August 31, 2022 10:00
@slimbuck slimbuck self-assigned this Aug 31, 2022
@mvaligursky
Copy link
Contributor

Could you please expand on this a bit more?
the rest is not treeshakable and is placed directly into index.js
What is 'the rest'?

@slimbuck
Copy link
Member Author

slimbuck commented Aug 31, 2022

What is 'the rest'?

All the bits not exposed by index.js. It isn't much - looks like just the polyfills.

@slimbuck
Copy link
Member Author

One of the questions is around naming of the output. With this PR in place, build/ folder contains:

playcanvas.js
playcanvas.mjs/
    index.js
    anim/
    ...
playcanvas.min.js
playcanvas.min.mjs/
    index.js
    anim/
    ...
...

I think this works ok. What do you think @willeastcott?

@willeastcott
Copy link
Contributor

Yes, I think this is fine. I mean, we can change what the package.json module field points to whenever we like and peoples' build processes should continue to work just fine.

@slimbuck slimbuck merged commit 9c15c2e into playcanvas:main Sep 1, 2022
@slimbuck slimbuck deleted the module-build branch September 1, 2022 12:06
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.

3 participants