deno: es module imports in repl don't work

When in the Deno REPL and executing: import { env } from "deno";

The output is: SyntaxError: Unexpected token {

Probably related to #1158

Executing: deno -v on the commandline returns: deno: 0.2.1 v8: 7.1.302.4 typescript: 3.2.1

About this issue

  • Original URL
  • State: closed
  • Created 6 years ago
  • Reactions: 7
  • Comments: 18 (14 by maintainers)

Most upvoted comments

That isn’t a TypeScript feature persay… import is valid ES6 syntax. But imports in general don’t work in the REPL, which is a known limitation. Native ESM support is being worked on (tracked by #975) and it should flow through to the REPL eventually.

The deno namespace though is available in the global scope, so const { env } = deno; would work for now.

Typescript isn’t supported in the repl yet, #1158.

if you’re claiming some new improved runtime, just seems lazy not to support imports in the repl so that they can be identical to scripts when run. dynamic reports requires non-zero time from end users when trying/converting examples, developing scripts etc. and my money is that adoption of your project will suffer for it

Fixed in https://github.com/denoland/deno/pull/7784; dynamic imports is the way to go when importing in REPL

If this is impossible… Perhaps import could be translated to import () prior to evaluation e.g. with regex. Or, perhaps less drastically, but less usefully, the repl could suggest import() syntax be used upon seeing this error (and regex match).

Or what about your collective conduct as maintainers provided a “welcoming environment”?

You have the wrong idea here: neither me nor @caspervonb are maintainers, we are contributors.

you wanna let me know what exactly I violated in that code of conduct?

Your behaviour has been hostile, and you have been violating the CoC:

  • Please be kind and courteous. There’s no need to be mean or rude.
  • Respect that people have differences of opinion and that every design or implementation choice carries a trade-off and numerous costs. There is seldom a right answer.
  • We will exclude you from interaction if you insult, demean or harass anyone. That is not welcome behavior.

and other points in the CoC.

Hopefully you’re getting some of that to work on your blessed repl implementation 😃

Well the repl is constantly getting improved, alongside the rest of the codebase. just some things have higher priority than the others. The repl is for quick debugging & trying things out. Having modules in the form of dynamic modules over static modules makes sense in the environment of a repl, where things are dynamic and not statically known, so no module can be made for the running repl, thus not allowing static imports. I am not sure if this can be changed or not, but if it can, it definitively is not a simple task, else it would have been done so from the beginning. Adding this functionality is not a priority.