carton icon indicating copy to clipboard operation
carton copied to clipboard

Publish `carton` as npm package

Open MaxDesiatov opened this issue 2 years ago • 4 comments

Based on a discussion with one of our users, it would make sense to publish carton on npm, similarly to how esbuild or swc provide binaries on npm. This would allow users primarily relying on npm to integrate carton and its commands into their npm-based workflow.

MaxDesiatov avatar May 12 '22 12:05 MaxDesiatov

A side benefit of this would be that anyone with Node installed would be able to run npx carton dev with no other install required.

j-f1 avatar May 12 '22 12:05 j-f1

FWIW: wasm-pack provides similar package https://github.com/rustwasm/wasm-pack/tree/master/npm

kateinoigakukun avatar May 12 '22 13:05 kateinoigakukun

We need to take into account https://github.com/apple/swift-package-manager/pull/3905. Until that's merged, we'll have to build with --static-swift-stdlib on Linux. Which we probably should be doing already anyway?

MaxDesiatov avatar May 12 '22 13:05 MaxDesiatov

Potential API for the package to be callable from other build tools (suggested by @ephemer)

const carton = require("carton");

carton.build("/package/to/package.swift").then(result => {
  console.log(result.wasmPath)
  console.log(result.javascriptSource)
});

MaxDesiatov avatar May 19 '22 12:05 MaxDesiatov

It now became a SwiftPM Plugin, so don't need to publish it as npm package now.

kateinoigakukun avatar Mar 11 '24 06:03 kateinoigakukun