ES modules: yay or nay?

Now that every major browser supports them will you guys eventually refactor @George? Also SC.
Or is it not on the table?

I know for AC components it will depend on the creator of the library to provide a bundled ESM build. Unless of course you implement Vite and Rollup and it becomes irrelevant if they provide a bundled build.

Are there any benefits to ES modules?
I have used it just once, and only found that the usage requires more code than a regular JS library integration.

A few benefits among others:

  • Same import/export statements for nodejs and browser
  • Import remote URLs
  • Tree shaking
  • Modularity
  • Ecmascript standard

Potentially you could install once using npm and use on both node and browser, but for that the developer of the library needs to provide a bundled ES module.

I’m new to JS learning etc, yesterday I wanted to do import / export in JS files and got a message "Parsing error: ‘import’ and ‘export’ may appear only with ‘sourceType: module’ ". Is that related to what you’re talking about here?

Well in the browser it is easy, you can always bundle and eventually support ESM natively.

We will be doing just that eventuality moving to full ES6 modules in the browser with App Connect. It might be however with the next major App Connect version as many things will have to change and we can implement also some new core optimizations. So it might take a while to get there.

In NodeJS and server Connect there is a different story. The current NodeJS community is a bit divided between CJS and ESM supporters. And the problem is you can’t mix them. So there is no clear migration path.

https://webreflection.medium.com/cjs-vs-esm-5f8b90a4511a

So we will be wait for the duets to settle before converting any SC stuff.

1 Like

Npm install:

https://9gag.com/gag/az9AnyB

4 Likes

It’s like work.

You always know when it starts, not when it ends.

1 Like

Yes, slightly. Those are the statements to import/export ES Modules.

@george bookmark this one in case it’s not already on your radar. Useful tool for codebase refactors, possibly for ESM refactor.

1 Like