{"id":48278,"library":"json-schema-loader","title":"json-schema-loader","description":"Webpack loader that resolves internal and external JSON Schema references ($ref) using json-schema-ref-parser. Version 1.0.0 is the first stable release. Supports both JSON and YAML schemas. Part of the Cloudflare doca suite. Provides options like useSource to enable chaining with other loaders. Useful for any webpack project that needs to resolve JSON Schema references at build time.","status":"active","version":"1.0.0","language":"javascript","source_language":"en","source_url":"https://github.com/cloudflare/json-schema-loader","tags":["javascript"],"install":[{"cmd":"npm install json-schema-loader","lang":"bash","label":"npm"},{"cmd":"yarn add json-schema-loader","lang":"bash","label":"yarn"},{"cmd":"pnpm add json-schema-loader","lang":"bash","label":"pnpm"}],"dependencies":[{"reason":"Core dependency used to resolve $ref references in JSON schemas.","package":"json-schema-ref-parser","optional":false}],"imports":[{"note":"Loader syntax is used in webpack. The loader returns the resolved schema object as a default export.","wrong":"const resolvedSchema = require('json-schema-loader!./schema.json');","symbol":"resolvedSchema","correct":"import resolvedSchema from 'json-schema-loader!./schema.json';"},{"note":"Webpack 4+ uses 'rules' instead of 'loaders'. The loader is compatible with webpack 4 and 5.","wrong":"module.exports = { module: { loaders: [ { test: /\\.json$/, exclude: /node_modules/, loader: 'json-schema-loader' } ] } };","symbol":"webpack rule","correct":"module.exports = { module: { rules: [ { test: /\\.json$/, exclude: /node_modules/, loader: 'json-schema-loader' } ] } };"},{"note":"Query parameters are passed to the loader's options. 'useSource' is a boolean option.","wrong":"const schema = require('json-schema-loader!./schema.json?useSource=true');","symbol":"options","correct":"import schema from 'json-schema-loader?useSource=true!./schema.json';"}],"quickstart":{"code":"// webpack.config.js\nmodule.exports = {\n  module: {\n    rules: [\n      {\n        test: /\\.json$/,\n        exclude: /node_modules/,\n        loader: 'json-schema-loader',\n        options: {\n          useSource: false\n        }\n      }\n    ]\n  }\n};\n\n// app.js\nimport schema from './schema.json';\nconsole.log(schema);","lang":"javascript","description":"Shows how to configure webpack to use json-schema-loader for all JSON files except node_modules, and then import a resolved schema in a module."},"warnings":[{"fix":"Set options.useSource=true to pass the raw source to json-schema-ref-parser instead of the file path.","message":"Loader does not work with webpack's built-in JSON parser if you chain loaders without setting useSource=true.","severity":"gotcha","affected_versions":">=1.0.0"},{"fix":"Prefer configuring the loader in webpack.config.js rather than using inline loader syntax.","message":"Webpack loaders syntax with require or import statements using ! is deprecated in favor of inline loader syntax.","severity":"deprecated","affected_versions":">=1.0.0"},{"fix":"Ensure the test pattern only matches relevant schema files, or use exclude patterns to avoid non-schema JSON files.","message":"The loader expects JSON or YAML files. Using it on non-schema files will cause runtime errors or unexpected behavior.","severity":"gotcha","affected_versions":">=1.0.0"}],"env_vars":null,"search_vec":"'1.0.0':23 'build':64 'chain':47 'cloudflar':38 'doca':39 'enabl':46 'extern':11 'first':26 'intern':9 'javascript':66 'json':2,12,18,31,60 'json-schema-load':1 'json-schema-ref-pars':17 'like':43 'loader':4,6,50 'need':57 'option':42 'parser':21 'part':35 'project':55 'provid':41 'ref':15,20 'refer':14,62 'releas':28 'resolv':8,59 'schema':3,13,19,34,61 'stabl':27 'suit':40 'support':29 'time':65 'use':16,51 'usesourc':44 'version':22 'webpack':5,54 'yaml':33","created_at":"2026-06-07T16:55:48.850112+00:00","updated_at":"2026-06-07T16:55:48.850112+00:00","problems":[{"fix":"Set options.useSource=true so the loader processes the raw source before other loaders.","cause":"The loader is chained with another loader that outputs JavaScript, but useSource is not set to true.","error":"Error: Module parse failed: Unexpected token in JSON at position 0"},{"fix":"Run npm install json-schema-loader --save-dev.","cause":"json-schema-loader is not installed or not in node_modules.","error":"Error: Cannot find module 'json-schema-loader'"},{"fix":"Configure the loader in webpack.config.js instead of using inline syntax.","cause":"Using inline loader syntax with require might cause webpack to warn about dynamic requires.","error":"Critical dependency: require function is used in a way in which dependencies cannot be statically extracted"}],"ecosystem":"npm","meta_description":null,"install_score":null,"quickstart_score":null,"quickstart_tag":null,"pypi_latest":null,"cli_name":null,"cli_version":null,"type":"library","homepage":"https://github.com/cloudflare/json-schema-loader#readme","github":"https://github.com/cloudflare/json-schema-loader","docs":null,"changelog":null,"pypi":null,"npm":"json-schema-loader","openapi_spec":null,"status_page":null,"smithery":null,"categories":["devops"],"base_url":null,"auth_type":null,"provenance":{"verified_status":null,"verified_at":null,"last_verified":"2026-06-07","next_check":"2026-09-05","install_tag":null}}