CLI to transpile individual ESM packages to CommonJS with esbuild.
Install
pnpm i -g transpile-node-modules
Usage
transpile-node-modules <pkg> [target]
pkg
- package to transpiletarget
- optional target environment (default: es2018)
🧪 CLI to transpile individual ESM packages to CommonJS with esbuild
License: MIT License
CLI to transpile individual ESM packages to CommonJS with esbuild.
pnpm i -g transpile-node-modules
transpile-node-modules <pkg> [target]
pkg
- package to transpiletarget
- optional target environment (default: es2018)First, I noticed there are two npm packages (same author) linked to this repo:
0.0.1 https://www.npmjs.com/package/transpile-node-modules
can't work
0.0.3 https://www.npmjs.com/package/esmtocjs-cli
works but #2
Would you consider updating repo code to the latest 0.0.3?
so that people like me can fork and do some further work on it.
Thanks for your work, that's awesome
I'm trying to use it to transpile ESM node_modules like strip-json-comments
esmtocjs strip-json-comments
but it still throws:
const stripJsonComments = require('strip-json-comments')
^
Error [ERR_REQUIRE_ESM]: require() of ES Module /Users/fritx/g/jsonmerge/node_modules/.pnpm/[email protected]/node_modules/strip-json-comments/index.js from /Users/fritx/g/jsonmerge/jsonc.js not supported.
Instead change the require of index.js in /Users/fritx/g/jsonmerge/jsonc.js to a dynamic import() which is available in all CommonJS modules.
at Object.<anonymous> (/Users/fritx/g/jsonmerge/jsonc.js:4:27)
It seems that we should remove type: "module"
also in package.json?
- "type": "module",
"exports": "./index.js",
+ "main": "./index.cjs"
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.