javascript - 条件导入 Deno
问题描述
我希望我的配置文件是可选的,我想到了这个解决方案,检查配置文件是否存在并有条件地导入我的配置文件,但我得到An import declaration can only be used in a namespace or module.deno-ts(1232)
.
app.ts
import {existsSync} from 'https://deno.land/std/fs/mod.ts'
if (existsSync('./myconfig.ts')) {
import {config} from './myconfig.ts'
}
myconfig.ts
export const config: any = {
config: "value"
}
解决方案
推荐阅读
- java - 为什么 scan.next() + scan.nextLine() 而不是 scan.nextLine()
- r - Pairing columns and making dataframe from wide to long in r
- c# - 使用 LINQ 对列表进行排序或排序并输出到列表框中
- makefile - 检查 makefile 中的 ifort/icc 版本
- go - 使用服务帐户从 Google REST API 获取数据
- powerbi - M 语言 - 除以字段的 MAX()
- c# - Xpath 表达式等于不起作用但大于?
- django - 如何在python中将orderdict转换为json?
- java - 每次执行后更改 @Schduled 注解内的 cron 值
- ios - UITextView 根据 UITableViewCell 中的文本动态宽度