curlconverter / curlconverter

Transpile curl commands into Python, JavaScript and 27 other languages
https://curlconverter.com
MIT License
7.15k stars 861 forks source link

stand alone library? #648

Open byersolomongmail opened 1 month ago

byersolomongmail commented 1 month ago

it would be very useful to have the stand-alone library hosted on jsdeliver with the tree-sitter and everything it is very hard to follow the node_modules packaging and the massive tree-sitter.

byersolomongmail commented 1 month ago

for a sort of working solution git clone https://github.com/curlconverter/curlconverter.github.io.git docker build -f ./docker/Dockerfile -t curlconverter.github.io-nginx . docker run -d -p 8080:80 docker ps docker cp :/usr/share/nginx/html /path/to/local/directory the local path has to be the root public path open to the web for this to work as otherwise the tree-sitter.wasm will fail now you can use the converter in an iframe.

verhovsky commented 1 month ago

have the stand-alone library hosted on jsdeliver

I looked at their website and I don't see what I have to do to get them to host it. Don't they just host everything automatically?

byersolomongmail commented 1 month ago

IDK it's there and doesn't work gives errors. I am not as good at node and stuff. https://www.jsdelivr.com/package/npm/curlconverter-release I think there has to be a browserify that is run on it for it to work

chris48s commented 1 month ago

So I tried to do this a few days ago. This was my experience trying to use curlconverter from https://www.jsdelivr.com/package/npm/curlconverter


<script src="https://cdn.jsdelivr.net/npm/curlconverter@4.9.0/dist/src/index.min.js"></script>

throws

Uncaught SyntaxError: export declarations may only appear at top level of a module

because it is an ESModule


<script type="module" src="https://cdn.jsdelivr.net/npm/curlconverter@4.9.0/dist/src/index.min.js"></script>

throws

Uncaught TypeError: The specifier “yamljs” was a bare specifier, but was not remapped to anything. Relative module specifiers must start with “./”, “../” or “/”.

So then you have to build an importmap to resolve each dependency from jsDelivr:

<script type="importmap">
  {
    "imports": {
      "yamljs": "https://cdn.jsdelivr.net/npm/yamljs@0.3.0/dist/yaml.min.js",
      "tree-sitter": "https://cdn.jsdelivr.net/npm/tree-sitter@0.21.1/index.min.js",
      // ..and so on
    }
  }
</script>
<script type="module" src="https://cdn.jsdelivr.net/npm/curlconverter@4.9.0/dist/src/index.min.js"></script>

at this point I gave up, fired up webpack, and just built my own bundle :D


I think the request here is to publish a built asset as part of the package which has all the dependencies bundled so that it can be pulled in as a single file from jsDelivr that is usable in the browser.