Open uga-rosa opened 6 days ago
Version: Deno 1.44.1
I want to use parse() of @babel/parser
parse()
@babel/parser
https://babeljs.io/docs/babel-parser#babelparserparsecode-options
import { parse } from "npm:@babel/parser"; const ast = parse("const foo = {};"); console.log(ast);
Referring to the type definition of parse(). The reason is that this @babel/types cannot be resolved.
@babel/types
import * as _babel_types from '@babel/types'; // ... declare function parse( input: string, options?: ParserOptions ): ParseResult<_babel_types.File>;
You can use import map to replace @babel with npm:@babel so that you can trace it.
@babel
npm:@babel
{ "imports": { "@babel": "npm:@babel" } }
However, in my actual application, I use Worker, so this workaround doesn't work, because import map doesn't work.
Worker
I tested with arktype, and got the same result
import { type } from "npm:arktype"; const user = type({ name: "string", });
Version: Deno 1.44.1
Summary
I want to use
parse()
of@babel/parser
https://babeljs.io/docs/babel-parser#babelparserparsecode-options
Cause
Referring to the type definition of
parse()
. The reason is that this@babel/types
cannot be resolved.Workaround
You can use import map to replace
@babel
withnpm:@babel
so that you can trace it.However, in my actual application, I use
Worker
, so this workaround doesn't work, because import map doesn't work.