Consider native ES6 module syntax?

I’m not sure how huge a request this is so forgive me if it’s out of the question, but I was surprised to see Nova extensions use CommonJS module conventions (module.exports, require()) rather than ES6 standard module syntax (import, export). In my career I sort of skipped from jQuery to ES6 modules without treading any of the ground in between, so there may be technical considerations that make this impossible or inadvisable, but it’s the sort of thing that would be better done sooner than later, so I thought I’d ask.

This is partially due to the underlying JavaScript engine, JavaScriptCore. import and export are not officially supported as syntax within it (it can only be used with transpilers, as far as I know?), and Nova does not transpile its extension code.

It’s something we can consider, but this was an easy (and fully supported) mechanism that was supported on our oldest deployment target (macOS 10.14).

Huh. I think I just learned that JavaScript Core doesn’t support everything that Safari supports? Safari has supported ES6 modules for two or three versions now, I think, but jsc definitely doesn’t. Understood!

Yeah. It’s a bit weird. Safari implements the “web” part of the JavaScript bits, which includes the module import. As far as I’ve been able to tell, there’s no good way to expose this from pure JavaScriptCore (or, at least, from its public C or Objective-C interface).

1 Like