In the past days I've looked into ways to setup a project, where I just want to run individual scripts using ES6 module syntax. The environment would be vscode and it's code-runner extension to run a file at my discretion, so nodemon is not required.
While esm looks great, I'm under the impression that it promotes a project design where there is only one entry point, which is good if your creating a node app. What I'm looking at instead, is just having a project with a src directory containing sub-directories for different types of single file experiments that also use ES6 module syntax.
How do I use esm in this context and for this purpose?
Hi @MVSICA-FICTA!
You can use esm as an application or package loader. As an application loader you can execute scripts by way of
node -r esm ./path/to/script
assuming esm is resolvable _(as any other node_modules is)_ of the path you're in.
Thank-you for esm, here how it works in vscode code-runner :)
"code-runner.executorMap": { "javascript": "node -r esm $fullFileName" }
Thanks for the update @MVSICA-FICTA!
The code-runner VS Code extension looks neat!
Most helpful comment
Thank-you for esm, here how it works in vscode code-runner :)
"code-runner.executorMap": { "javascript": "node -r esm $fullFileName" }