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

A way to include jsep plugins as static pages #258

Open
meldckn opened this issue Dec 11, 2023 · 2 comments
Open

A way to include jsep plugins as static pages #258

meldckn opened this issue Dec 11, 2023 · 2 comments
Labels

Comments

@meldckn
Copy link

meldckn commented Dec 11, 2023

Hello! Is there a way to include JSEP-provided plugin functionality like assignment without needing to use Node and modules (and therefore needing to use a server to host my site)?

So, I'd like to use just <script src="jsep.min.js" type="text/javascript"></script> (and maybe another one for the assignment file?) in my html, rather than npm install @jsep-plugin/assignment and

import jsep from 'jsep';
import jsepAssignment from '@jsep-plugin/assignment';
jsep.plugins.register(jsepAssignment);

Background: jsep was especially appealing to me for its small size, lack of dependencies, and the ability to use it in a static site. I'm creating a small serverless web project. I have authors writing content for it who are non-technical, and I want to minimize the amount of setup they need to do to write content (like installing developer tools and using the command line). We don't have any other need for a server, and it doesn't make sense to move to a server just to be able to use this library. But if I could add the assignment plugin functionality, this library would be perfect for my use case! Thanks for your time and work on this!

@6utt3rfly
Copy link
Collaborator

Hi @meldckn ! If you don't want to host the packages, you could use one of the various NPM CDN services, like unpkg.com:

<script type="module">
  import jsep from 'https://unpkg.com/[email protected]/dist/jsep.min.js';
  import jsepAssignment from 'https://unpkg.com/@jsep-plugin/[email protected]/dist/index.min.js'
  jsep.plugins.register(jsepAssignment);
  const expressionTree = jsep.parse('a = 2');
  console.log(JSON.stringify(expressionTree, null, 2));
</script>

@meldckn
Copy link
Author

meldckn commented Dec 13, 2023

Thanks for the suggestion! I didn't know you could use a URL in an import call.

But wouldn't this mean I'd have to write all of the code that interacts with jsep and its output inside my index.html file? If so, that's not practical for my needs. Is there a way to de-"module"-arize the JSEP plugins?

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

No branches or pull requests

2 participants