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

Add Engine ESM build #6073

Merged
merged 6 commits into from
Feb 21, 2024
Merged

Add Engine ESM build #6073

merged 6 commits into from
Feb 21, 2024

Conversation

marklundin
Copy link
Member

This PR adds an additional ES6 bundle playcanvas.esm.js as a build output. It uses the same ES6 build configuration as the unbundled playcanvas.mjs but instead simply outputs to a single output.

We plan on upgrading the launcher and exported projects to use this ES6 build to support ESM Scripts.

I confirm I have read the contributing guidelines and signed the Contributor License Agreement.

@kungfooman
Copy link
Collaborator

Very nice, people needed this for quite some time - unbundled ESM builds were causing:

  • no problem for local development, but long request times for every individual file over internet
  • services like UNPKG have request limits and simply drop further ones

@marklundin
Copy link
Member Author

Very nice, people needed this for quite some time - unbundled ESM builds were causing:

  • no problem for local development, but long request times for every individual file over internet
  • services like UNPKG have request limits and simply drop further ones

Unfortunately even the ES Modules build includes these polyfils which are likely redundant

@@ -104,7 +105,7 @@ function buildTarget(buildType, moduleFormat, input = 'src/index.js', buildDir =

const outputExtension = {
es5: '.js',
es6: '.mjs'
es6: shouldBundle ? '.esm.js' : '.mjs'
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In the current file extension scheme .js means UMD, shouldn't we keep .mjs? Maybe something like playcanvas.bundled.mjs

Copy link
Member Author

@marklundin marklundin Feb 21, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah there's no easy answer here. playcanvas.mjs is the most obvious, and consistent with the UMD playcanvas.js build, but the .mjs suffix is currently pointing to a directory, and so I wonder if that build actually needs to be renamed

@mvaligursky
Copy link
Contributor

Should we have other flavours of this bundle? At least debug, performance, and release (normal).

@marklundin
Copy link
Member Author

Should we have other flavours of this bundle? At least debug, performance, and release (normal).

Yep there's the same outputs, dbg, prf and min

@slimbuck
Copy link
Member

slimbuck commented Feb 21, 2024

Had a little discussion among the team and we'd vote for:
playcanvas.js - the UMD build, as before
playcanvas.mjs - the ESM bundled version
playcanvas - the ESM unbundled version

And of course .dgb, .min, .profile version of each.

@kungfooman
Copy link
Collaborator

We also need to change in that case:

"module": "build/playcanvas.mjs/index.js",

@marklundin
Copy link
Member Author

Had a little discussion among the team and we'd vote for: playcanvas.js - the UMD build, as before playcanvas.mjs - the ESM bundled version playcanvas - the ESM unbundled version

And of course .dgb, .min, .profile version of each.

Love this. Done!

Assuming the unbundled 'playcanvas' dir doesn't need to have 'playcanvas.prf', 'playcanvas.min', 'playcanvas.dbg' variants

@marklundin
Copy link
Member Author

We also need to change in that case:

"module": "build/playcanvas.mjs/index.js",

Yep agreed. Have updated

@slimbuck
Copy link
Member

Assuming the unbundled 'playcanvas' dir doesn't need to have 'playcanvas.prf', 'playcanvas.min', 'playcanvas.dbg' variants

I think we will need variants... @mvaligursky ?

@marklundin
Copy link
Member Author

marklundin commented Feb 21, 2024 via email

@mvaligursky
Copy link
Contributor

If we expect people to use the unbundled versions, we need to provide the variants, as they cannot easily replicate our processes to strip out debug info, and they need debug version at the very least.

@slimbuck
Copy link
Member

For consistency naming the folders playcanvas, playcanvas.dbg, playcanvas.min, playcanvas.prf seems fine to me.

@slimbuck
Copy link
Member

Though in reality the .min unbundled build has no use whatsoever (the rest do).

@marklundin
Copy link
Member Author

Have added unbundled es6 variants excluding 'min' @slimbuck @mvaligursky

Copy link
Member

@slimbuck slimbuck left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

<3

@marklundin marklundin merged commit 80144e0 into main Feb 21, 2024
6 of 7 checks passed
@marklundin marklundin deleted the es6-bundle branch February 27, 2024 15:15
@marklundin marklundin changed the title Added ES6 bundle output Adds Engine ESM build Jul 10, 2024
@marklundin marklundin changed the title Adds Engine ESM build Add Engine ESM build Jul 10, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
Status: Done
Development

Successfully merging this pull request may close these issues.

4 participants