Skip to content

Commit 8d9eef6

Browse files
committed
Add json-loader plugin
1 parent b303a16 commit 8d9eef6

File tree

1 file changed

+17
-0
lines changed

1 file changed

+17
-0
lines changed

plugins/json.ts

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
import type { Plugin } from '../types.d.ts'
2+
3+
// todo: remove this plugin when deno support `json` module
4+
// check https://github.com/denoland/deno/issues/7623
5+
export default (): Plugin => {
6+
return {
7+
name: 'json-loader',
8+
setup: aleph => {
9+
aleph.onLoad(/\.json$/i, async ({ specifier }) => {
10+
const { content } = await aleph.fetchModule(specifier)
11+
return {
12+
code: `export default ` + new TextDecoder().decode(content)
13+
}
14+
})
15+
}
16+
}
17+
}

0 commit comments

Comments
 (0)