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

stand alone library? #648

Open
byersolomongmail opened this issue Mar 31, 2024 · 4 comments
Open

stand alone library? #648

byersolomongmail opened this issue Mar 31, 2024 · 4 comments

Comments

@byersolomongmail
Copy link

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

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 <image_name>
docker ps
docker cp <container_id_or_name>:/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
Copy link
Member

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

byersolomongmail commented Apr 2, 2024

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

chris48s commented Apr 2, 2024

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/[email protected]/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/[email protected]/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/[email protected]/dist/yaml.min.js",
      "tree-sitter": "https://cdn.jsdelivr.net/npm/[email protected]/index.min.js",
      // ..and so on
    }
  }
</script>
<script type="module" src="https://cdn.jsdelivr.net/npm/[email protected]/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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Development

No branches or pull requests

3 participants