-
Notifications
You must be signed in to change notification settings - Fork 33
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Bundled index JS with webpack or esbuild unrunnable #620
Comments
Hi, thanks for asking. To me it sounds like a bug in the bundler, but since I'm also the author of @seriousme/openapi-schema-validator. I will take a look to see if I can fix it. Kind regards, |
I just released Hope this helps. |
Looking at it again I think that although the function importJSON(file) {
return JSON.parse((0,external_node_fs_namespaceObject.readFileSync)(localFile(file)));
} The reason for that is that build tools that are intended for browsers have no notion of filesystem and I might be able to fix this using Just out of curiosity: why do you bundle serverside code using browser bundlers? Kind regards, |
Hey there,
First of all, great package. Made things a lot easier for our API project.
I'm facing some issues using this package because of a dependency - specifically @seriousme/openapi-schema-validator. I believe looking at the code this is using a URL object and building a path to select a version of openapi to validate against (a JSON that is read in at runtime).
Problem with this is that if you'd like to bundle all your code into one file / runtime like we do, this file will not come with it. In fact, bundlers seem to replace the URL with an absolute path pointing at the module which is a bit weird for sure (see code at bottom taken from the compiled code).
Do you have any advice on this / perhaps we could consider importing it into this file in some way to make the connection easier for bundlers to understand? I will continue to look at options as I may be able to assist with a merge request on this library
`const openApiVersions = new Set(["2.0", "3.0", "3.1"]);
const ajvVersions = {
"http://json-schema.org/draft-04/schema#": dist,
"https://json-schema.org/draft/2020-12/schema": _2020,
};
const inlinedRefs = "x-inlined-refs";
function localFile(fileName) {
return (0,external_node_url_.fileURLToPath)(new external_node_url_.URL(fileName, "file:///Users/XXXX/Documents/projects/XXXX/node_modules/@seriousme/openapi-schema-validator/index.js"));
}
function importJSON(file) {
return JSON.parse((0,external_node_fs_namespaceObject.readFileSync)(localFile(file)));
}`
The text was updated successfully, but these errors were encountered: