Skip to content
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

Webpack and Babel #290

Closed
philsturgeon opened this issue Nov 26, 2022 · 4 comments
Closed

Webpack and Babel #290

philsturgeon opened this issue Nov 26, 2022 · 4 comments

Comments

@philsturgeon
Copy link
Member

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
Copy link
Member Author

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

@wparad
Copy link
Contributor

wparad commented Nov 29, 2022

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

@kevinswiber
Copy link

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.

@philsturgeon
Copy link
Member Author

@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

@jonluca jonluca closed this as completed Mar 6, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants