Skip to content
This repository was archived by the owner on Aug 1, 2024. It is now read-only.

Commit 649d888

Browse files
[minor] Added default loader settings
In previous versions, the `loader` was `undefined` by default. This caused some errors when loading remote files. Instead, we defined a default loader for `js`, `jsx`, `ts`, `tsx`, `css`, `json` and `text` files.
1 parent e51ab74 commit 649d888

File tree

1 file changed

+18
-0
lines changed

1 file changed

+18
-0
lines changed

mod.ts

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,16 @@ interface Options {
1818
}];
1919
}
2020

21+
const defaultLoaderRules = [
22+
{ test: /\.(c|m)?js$/, loader: 'js' },
23+
{ test: /\.jsx$/, loader: 'jsx' },
24+
{ test: /\.(c|m)?ts$/, loader: 'ts' },
25+
{ test: /\.tsx$/, loader: 'tsx' },
26+
{ test: /\.json$/, loader: 'json' },
27+
{ test: /\.css$/, loader: 'css' },
28+
{ test: /\.txt$/, loader: 'text' },
29+
];
30+
2131
function esbuildCachePlugin(options: Options): esbuild.Plugin {
2232
const namespace = 'esbuild-cache-plugin';
2333
if (options.directory) {
@@ -82,6 +92,14 @@ function esbuildCachePlugin(options: Options): esbuild.Plugin {
8292
break;
8393
}
8494
}
95+
if(typeof loader === 'undefined') {
96+
for (const rule of defaultLoaderRules) {
97+
if(rule.test.test(args.path)) {
98+
loader = rule.loader;
99+
break;
100+
}
101+
}
102+
}
85103

86104
return {
87105
contents: await Deno.readTextFile(file.path),

0 commit comments

Comments
 (0)