nim_config icon indicating copy to clipboard operation
nim_config copied to clipboard

Idea: Option for target NodeJS and generate *.min.js

Open juancarlospaco opened this issue 5 years ago • 3 comments

  • [ ] Implement an option to target NodeJS js -d:nodejs -d:release.
  • [ ] When used it should generate a *.js and *.min.js.
  • [ ] What else is needed, lets say I want to publish my Nim module as NPM module :grey_question:

For the "Backend" of this idea please have a look at:

  • https://parceljs.org/cli.html
  • https://parceljs.org

juancarlospaco avatar Oct 25 '18 09:10 juancarlospaco

That's a great idea. FYI, I have no JS or npm knowledge. But if you are leading this effort, I follow that PR closely (you can start a WIP PR as you get something going), and I can chime in wherever I can help.

Thanks.

kaushalmodi avatar Oct 25 '18 11:10 kaushalmodi

To publish to npm, you need a file called package.json. There's a few keys you should have:

{
  "name": "my-lib-rulez",
  "version": "1.0.1",
  "license": "MIT",
  "files": ["readme.md", "dist"],
  "main": "dist/my-lib-rules.min.js"
}

Your build process should compile (optionally minify -- though i wouldn't sweat it these days) and drop it in a .gitignore'd dist directory (name is subjective - though dist is popular).

To publish, you type npm publish. npm then makes a tarball based on the packing list of files/dirs found in your files key in your package.json and uploads that to the central npm repository for everyone to access.

The tooling landscape in JavaScript is vast, but by sticking to the bare minimum steps, it's actually quite simple.

EDIT 1,2: i can't type json in a textarea to save my life.

skellock avatar Oct 25 '18 13:10 skellock

I think that calling js -d:nodejs -d:release should be relatively easy. The rest might need more research or someone with experience on NPM.

juancarlospaco avatar Oct 28 '18 09:10 juancarlospaco