44 *
55 * If you would like to use this package in a Node.js project, you'll need to use native ESM or a transform system
66 */
7- import * as esbuild from 'https://deno.land/x/esbuild@v0.17.5 /mod.js'
7+ import * as esbuild from 'https://deno.land/x/esbuild@v0.20.1 /mod.js'
88import { parse } from 'https://deno.land/[email protected] /flags/mod.ts' 9+ import { denoPlugins } from "https://deno.land/x/[email protected] /mod.ts" 910
1011const MAIN_ENTRY = 'src/main.ts'
1112const CLI_ENTRY = 'src/bids-validator.ts'
1213
13- const httpPlugin = {
14- name : 'http' ,
15- setup ( build : esbuild . PluginBuild ) {
16- build . onResolve ( { filter : / ^ h t t p s ? : \/ \/ / } , ( args ) => ( {
17- path : args . path ,
18- namespace : 'http-url' ,
19- } ) )
20-
21- build . onResolve ( { filter : / .* / , namespace : 'http-url' } , ( args ) => ( {
22- path : new URL ( args . path , args . importer ) . toString ( ) ,
23- namespace : 'http-url' ,
24- } ) )
25-
26- build . onLoad ( { filter : / .* / , namespace : 'http-url' } , async ( args ) => {
27- const request = await fetch ( args . path )
28- const contents = await request . text ( )
29- if ( args . path . endsWith ( '.ts' ) ) {
30- return { contents, loader : 'ts' }
31- } else if ( args . path . endsWith ( '.json' ) ) {
32- return { contents, loader : 'json' }
33- } else {
34- return { contents, loader : 'js' }
35- }
36- } )
37- } ,
38- }
39-
4014const flags = parse ( Deno . args , {
4115 boolean : [ 'minify' ] ,
4216 default : { minify : false } ,
@@ -49,7 +23,7 @@ const result = await esbuild.build({
4923 outdir : 'dist/validator' ,
5024 minify : flags . minify ,
5125 target : [ 'chrome109' , 'firefox109' , 'safari16' ] ,
52- plugins : [ httpPlugin ] ,
26+ plugins : [ ... denoPlugins ( ) ] ,
5327 allowOverwrite : true ,
5428 sourcemap : flags . minify ? false : 'inline' ,
5529 packages : 'external' ,
0 commit comments