Comments (5)
Oh, I see- it's outputting JavaScript which is now a problem. One day it will be possible to do things in JS without stacking a bajillion constantly changing frameworks on top of each other. Maybe.
from json-schema-tools.
@ValYouW json-schema-ref-loader
understands several formats. If there is a .json
extension it will just try to parse it as JSON. I don't remember offhand what the default behavior is if the extension is unrecognized, but it's probably either YAML or JavaScript, both of which are more forgiving.
Given that you have module.exports
, it looks like your file is probably JavaScript and not plain JSON.
from json-schema-tools.
@handrews Hi, I don't have "module.exports", I have a regular json file:
{
"a": 123,
"b": ""B"
...
}
As I wrote, I think that json-schema-ref-loader is working OK, converting the json to a module (here) but since WebPack works in a loader-chain fashion there is probably a loader that comes after json-schema-ref-loader that expects to get a json file but gets the json-schema-ref-loader output, which is a module... this is my assumptions, I am trying to see if I can "disable" all the loaders that comes after json-schema-ref-loader in the chain...
from json-schema-tools.
OK, found that in WebPack 4 changelog:
JSON
webpack now handles JSON natively
You may need to add type: "javascript/auto" when transforming JSON via loader to JS
So I need to "tell" webpack that json-schema-ref-loader emits javascript, so it will know that the json file is no longer a json and won't try to parse it (webpack 4 parse json files natively)... the problem is that I can't do it for "inline loaders"...
from json-schema-tools.
OK, so to close this issue, this is what I ended up with:
- I removed the "inline loader" style when importing the schema
- Renamed all schema files to end with
.schema.json
- Defined the following module rule in my webpack config:
{
test: /\.schema\.json$/,
loader: '@cloudflare/json-schema-ref-loader',
type: 'javascript/auto',
exclude: /node_modules/
}
This way json-schema-ref-loader
will only handle my schema files and webpack will keep handling regular json
files...
Thx :)
from json-schema-tools.
Related Issues (16)
- Webpack warning when running examples HOT 9
- Error: Cannot find module '@cloudflare/json-hyper-schema' and other start-up bumps... HOT 6
- Getting yarn errors HOT 3
- doca - Create an option for schema glob
- json-schema-ref-loader can't handle circular references HOT 5
- Where is the schema for cloudflare api v4? HOT 13
- json-schema-ref-loader NPM package still has `console.error` in loader code.
- Module build failed: LoaderRunnerError: Module: '<path>/json-schema-apidoc-loader/lib/loader.js' is not a loader (must have normal or pitch function)
- Clearly document config.js (base URI and headers)
- Order of properties
- Windows support HOT 2
- Support "examples" (plural) from draft-06
- doca init -title <Title>
- Support project folder outside of working directory
- Webpack process only picks up some of the css files in a theme
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from json-schema-tools.