-
Notifications
You must be signed in to change notification settings - Fork 13
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
How to load with Typescript + npm package #40
Comments
Great question. This actually does not depend on Vue (or the Typescript typings). Depending on how your project is configured, this may depend on the bundler you are using to build your application. It could be Parcel, Rollup, Webpack, etc... A bundler will typically have a way of loading a module from the |
Got it working:
In a typings file (d.ts) or in a global.d.ts file, in the "src" directory: declare module "mathlive/dist/mathlive";
declare module "mathlive/dist/vue-mathlive"; Importing and using will then work just like the example on the main page. Just dont use a script tag, it's a regular Typescript import. And no need for file extensions either: import * as MathLive from "mathlive/dist/mathlive";
import VueMathfield from "mathlive/dist/vue-mathlive";
Vue.use(VueMathfield, MathLive);
Seems to be working as expected now. Of course, seeing as there are already typings for MathLive in the npm package, maybe there should be typings for the Wrapper too? Just a humble request, of course. No way I'm the only person that could use this. @arnog If you don't have any further remarks on this, you may close it. It's working enough for me. |
Great to hear you were able to get it working, thanks for the update. |
Hi, obviously a question, not a bug. If this is not the place to ask this, just tell me where to go.
I noticed that vue-mathlive.mjs already comes in the dist folder of the Mathlive npm package.
I don't understand however, how to load them into a Vue Typescript application.
This way doesn't work, no modules are found:
` import * as MathLive from "mathlive/dist/mathlive.min.mjs";
import VueMathfield from "mathlive/dist/vue-mathlive.mjs";
Vue.use(VueMathfield, MathLive); `
Also tried putting the whole path to node_modules. Same result.
I see that there are typescript typings for Mathlive. Should I just use those?
I don't have any other experience of trying to load Javascript modules into a TS project. Is there a way?
The text was updated successfully, but these errors were encountered: