json-schema-ref-parser icon indicating copy to clipboard operation
json-schema-ref-parser copied to clipboard

Webpack and Babel

Open philsturgeon opened this issue 3 years ago • 4 comments

I have zero experience in setting up Webpack and Babel but apparently that's going to be needed to ESMify this package and remove a lot of the old-school JS stuff in here.

Modernizing and deleting things to simplify life sounds good, and made #288 seem appealing, but it's turned into a bit of a mess as it now seems like we'll need to make everything completely ESM and then convert to CommonJS format with Babel?

If anyone can do this I will pay them money, and if anyone wants this but doesn't know how please sponsor the package so that I have money to pay whoever does it.

philsturgeon avatar Nov 26 '22 12:11 philsturgeon

Or do we use SWC as its quicker or something. https://blog.logrocket.com/why-you-should-use-swc/

philsturgeon avatar Nov 26 '22 13:11 philsturgeon

I recently wrapped this library to inline a bunch of things, and introduced babel, if someone picks this issue up the changes might provide some good inspiration: https://github.com/Rhosys/openapi-resolver.js

wparad avatar Nov 29 '22 12:11 wparad

I don't think Webpack or Babel are needed for this. If we want the codebase to be ESM, we can set type to module in package.json and have conditional exports that look like:

{
  "exports": {
    "import": "lib/index.js",
    "require": "lib/index.cjs"
  }
}

Then index.cjs can re-export what's in index.js but for CommonJS. This should work for Node versions all the way back to 12.6.x.

kevinswiber avatar Nov 29 '22 17:11 kevinswiber

@kevinswiber oh if that works then brilliant! I had a quick go and again clearly don't know what I'm doing because my wild stabs are giving more errors.

image

philsturgeon avatar Dec 02 '22 21:12 philsturgeon