deno: 0.10.0
v8: 7.7.37
typescript: 3.5.1
When you try to import an ecmascript module using the REPL, you get an Uncaught SyntaxError:
> import Drash from "https://deno.land/x/[email protected]/mod.ts";
error: Uncaught SyntaxError: Unexpected identifier
â–º <unknown>:1:8
at evaluate (js/repl.ts:87:34)
at replLoop (js/repl.ts:145:13)
Node.js allows CommonJS module loading using their REPL, but I'm unable to import ES modules there either: https://stackoverflow.com/questions/56963708/.
(duplicate of #1285)
Dup of #1285. This is expected. ES Module is slightly different from require as resolution is asynchronous, and could only exist in module level (e.g. in an independent file). Also see https://medium.com/the-node-js-collection/an-update-on-es6-modules-in-node-js-42c958b890c
REPL works differently: it takes your code and eval under a context, without creating new modules. So static import statements are unexpected.
What you want is actually the dynamic import. I think Ryan has a WIP implementation for it, so it should be available soon. See https://v8.dev/features/dynamic-import
I think currently if we really want to do this, there are only 2 solutions:
@kevinkassimo : I should have thought of that!