Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

How to import other extension file with Deno. #20469

Closed
BoltDoggy opened this issue Sep 12, 2023 · 4 comments
Closed

How to import other extension file with Deno. #20469

BoltDoggy opened this issue Sep 12, 2023 · 4 comments

Comments

@BoltDoggy
Copy link

import config from 'config.yaml'

Like: https://bun.sh/docs/runtime/plugins

I need a loader at preload step.

@markthree
Copy link
Contributor

markthree commented Sep 13, 2023

import config from 'config.yaml'

Like: https://bun.sh/docs/runtime/plugins

I need a loader at preload step.

As far as I know, loader is not currently supported. You can try using the following code to load yaml

import { parse } from "https://deno.land/[email protected]/yaml/mod.ts";

const configText = await Deno.readTextFile("./config.yaml");

const config = parse(configText);

console.log(config);

@BoltDoggy
Copy link
Author

@markthree 目的不太一样, 因为 deno 支持 bundle, 使用 readTextFile 不能将 config.yaml 也加入到 bundle 中, 而 preload 的插件可以将 config.yaml 处理成 ts 可执行的代码并加入到 bundle, 类似 webpack 可以把 png 等文件变成 base64 加入到 js 产物.

deno 支持直接 run 一个远程 js 链接来启动 server, 但是大多数 server 都是包含 static file 的, 所以 deno deploy 只能靠支持 github 仓库整个 clone 来实现.

如果支持了 preload, 那么 bundle 后的产物就可以完全的做到 run 一个远程 js 路径.

@markthree
Copy link
Contributor

@markthree 目的不太一样, 因为 deno 支持 bundle, 使用 readTextFile 不能将 config.yaml 也加入到 bundle 中, 而 preload 的插件可以将 config.yaml 处理成 ts 可执行的代码并加入到 bundle, 类似 webpack 可以把 png 等文件变成 base64 加入到 js 产物.

deno 支持直接 run 一个远程 js 链接来启动 server, 但是大多数 server 都是包含 static file 的, 所以 deno deploy 只能靠支持 github 仓库整个 clone 来实现.

如果支持了 preload, 那么 bundle 后的产物就可以完全的做到 run 一个远程 js 路径.

嗯嗯,deno 并不支持这种 preload,据我了解 deno bundle 已被弃用,未来可能会被直接移除,所以未来可能加入 loader 的机率也是比较小的。

可以试试用 esbuildrollupdeno_emit 来实现这一点。


Hmm, Deno does not support this type of preload. As far as I know, the Deno bundle has been deprecated and may be directly removed in the future, so the probability of adding loader in the future is also relatively low. You can try using esbuild, rollup, or deno_emit to achieve this.

@lucacasonato
Copy link
Member

This is not currently supported. #1739

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants