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

[feature request] manual select between browser and nodejs mode when create new RiveScripr object #317

Open
MrBokeh opened this issue Jul 22, 2019 · 2 comments

Comments

@MrBokeh
Copy link

MrBokeh commented Jul 22, 2019

[feature request] manual select between browser and nodejs mode when create new RiveScripr object to allow any front end library like angular which use npm to import module would work nicely.

E.g. const rivescript = new RiveScript({mode:”browser”});

@kirsle
Copy link
Member

kirsle commented Jul 22, 2019

What does your workflow look like when you use RiveScript with Angular?

Webpack is commonly used for bundling a JavaScript app for web browsers (creating a single bundled.min.js script to include in your HTML), and before that, Browserify was one people used. RiveScript-js used those to produce the dist/rivescript.js bundle for easy web browser embedding, and both of these tools would set the process.browser variable for run-time detection in the script.

The raw Node.js sources for RiveScript aren't suitable for a browser (no require() keyword supported), so your workflow must be doing something to bundle them? If so there might be a way to auto-detect it that RiveScript could use instead.

I do like the idea of a constructor option fallback just in case, but curious to hear what you're doing with Angular and RiveScript.

@MrBokeh
Copy link
Author

MrBokeh commented Jul 23, 2019

Auto-detect is a nice feature but in some cases for some frontend projects that do not use Webpack nor Browserify for bundling and run their npm packages would have troubles to run. I use TypeScript which is the default standard language for both Angular and React but it does not use Webpack nor Browserify, so it would be very nice to have a fallback option.

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