So, if you have a project that has a bit of a historic that's been in place for a while, maybe ESM wasn't around them using CGS, it can make sense. Yeah, it's still interesting to see.
Yes, okay. So let's take some Q and A's of the questions, audience questions. So, okay, so we have a question on slide number 18, you mentioned it is not possible to import version from a JSON in one line, but it works in two lines. What are the difference between two syntaxes? Okay, yeah, so, yeah, it's a bit, maybe a bit tricky if you're not used to the ESM syntax. When you're working with JSON files with required calls, you can simply to that in one line, import one part, one chunk of the JSON file. And that doesn't work in the ESM syntax, that's mainly for performance reasons. So when the JavaScript engine reads your import, it has to know if this, what you're importing actually exists. And it would be too costly for it to read the JSON file at this stage. So that's why it's forbidden. And it might feel arbitrary if you're not used to it. But yeah, just something to have in mind on the. But yeah. Yeah, so get everything and then get the version out of that. So, okay.
So we have another question. Do you think with TC39 adopting types as comments and native ESM by bundling over time, ESM will gain more users? Yeah, so it's hard to predict. How the JavaScript ecosystem will adapt those things. I certainly hope it will happen because I think ESM is really awesome and is the future of JavaScript. And certainly helping reduce the gap between what the users want to write as code should help. So, yeah, I'd like to answer yes to the question, but it will depend on everyone else, you know. Yeah, it's always tricky. Yeah, I would say, but it can go either way. But yeah, let's see what future holds for that.
So, we have another question from Uswal. So, there is a few concerns people have raised with ESM. For example, it's inability to do things like const, some initialize module equal to require, then module name, and then calling it with some options. What do you think is an appropriate way to overcome this? Yeah, so it's a bit like the first question. Using the ESM syntax makes you sometimes use two lines instead of what could have been one incoming JS.
Comments