Skip to content

Commit 39baeb8

Browse files
authored
Merge pull request #1912 from nellh/web-build-fixes
schema: Fixes for web builds
2 parents 70dcc1a + c884ffd commit 39baeb8

File tree

2 files changed

+4
-30
lines changed

2 files changed

+4
-30
lines changed

bids-validator/build.ts

Lines changed: 3 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -4,39 +4,13 @@
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'
88
import { parse } from 'https://deno.land/[email protected]/flags/mod.ts'
9+
import { denoPlugins } from "https://deno.land/x/[email protected]/mod.ts"
910

1011
const MAIN_ENTRY = 'src/main.ts'
1112
const CLI_ENTRY = 'src/bids-validator.ts'
1213

13-
const httpPlugin = {
14-
name: 'http',
15-
setup(build: esbuild.PluginBuild) {
16-
build.onResolve({ filter: /^https?:\/\// }, (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-
4014
const 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',

bids-validator/src/setup/loadSchema.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ export async function loadSchema(version = 'latest'): Promise<Schema> {
1818
schemaUrl = `https://bids-specification.readthedocs.io/en/${version}/schema.json`
1919
}
2020
try {
21-
const schemaModule = await import(schemaUrl, {
21+
const schemaModule = await import(/* @vite-ignore */ schemaUrl, {
2222
assert: { type: 'json' },
2323
})
2424
return new Proxy(

0 commit comments

Comments
 (0)