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

Use in ES6. #16

Closed
gskinner opened this issue Apr 12, 2019 · 4 comments
Closed

Use in ES6. #16

gskinner opened this issue Apr 12, 2019 · 4 comments

Comments

@gskinner
Copy link

gskinner commented Apr 12, 2019

Just to confirm - if I wanted to use this in an ES6 project targeted at the browser, I assume I'm going to need to use the TS compiler to transpile to ES6. Is there a better approach, and/or any other gotchas I should be aware of?

@zikaari
Copy link
Owner

zikaari commented Apr 14, 2019

You don't need to transpile anything. Everything is ready-to-go out of the box.

When you npm i onigasm, you get the transpiled files contained in node_modules/onigasm/lib/** and pointed at by node_modules/onigasm/package.json::main property.

However, if you're planning to build it yourself, package.json's scripts has everything you need.

Just npm run build. Just make sure you have all the deps ready, which is TypeScript and Emscripten (install instructions can be found on Emscripten's website)

PS: Please don't forget to leave a comment in atom/node-oniguruma#81 which is something you'll like. If they don't respond within a reasonable time frame we'll just go ahead and merge #14

@gskinner
Copy link
Author

Unless I'm missing something, the default output, as installed by npm is targeted at Node.js, and has dependencies on specific capabilities such as require. I could potentially work around this by including something like Browserify in our app, but I'd prefer to avoid that.

@zikaari
Copy link
Owner

zikaari commented Apr 14, 2019

It isn't targeted at Node.js, instead, it just uses the same module loading method as Node.js; CommonJS that is.

In fact, the build process goes an extra mile to ensure no require calls to native modules live in the final output. require('fs') for example.


onigasm package intrinsically assumes consumers to be using some sort of "bundler", preferably Webpack. And it just works™.

I see you're using rollup. I'm quite confident that if you do import { loadWASM } from 'onigasm' it'll work just as good.

You might need rollup plugins like commonjs loader or similar if you don't have already.

@zikaari
Copy link
Owner

zikaari commented May 31, 2019

Closing as stale. Feel free to re-open if necessary.

@zikaari zikaari closed this as completed May 31, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants