Skip to content

ESMs are always file-based

ES Modules

First, there’s no wrapping function to define a module. The
wrapping context is a file. ESMs are always file-based; one
file, one module.

I found this sentence from “you don’t know js by kyle simpson”.What is he meant by ESMs are always file-based; one file, one module.Does that mean one java script file can only contains one module

Answer

Does that mean one java script file can only contains one module

Yes. Every JavaScript module file contains exactly one module. You can’t have a module file with more than one module in it.