Add standalone script compatibility - #30
Conversation
| "webpack-cli": "^3.3.11" | ||
| }, | ||
| "engines": { | ||
| "node": ">= 6.0.0" |
There was a problem hiding this comment.
What is the engine requirement based on?
There was a problem hiding this comment.
Webpack had some mention of it being sometimes necessary to specify. I think it was webpack's minimum supported version of node.
I just removed it since it's no longer necessary.
|
Hi! Unfortunately I don't use Webpack regularly, and would prefer not to take on maintaining a build artifact that requires it. Would microbundle's It'd be fine to omit |
|
Yeah, microbundle works great, I didn't know it existed. |
|
NPM is reporting that microbundle has several security vulnerabilities. So I added a notice not to use the standalone scripts in production at the moment. |
Webpack had some mention of it being sometimes necessary to specify.
|
Shouldn't those vulnerabilities only affect the |
|
Right, the vulnerabilities are essentially false positives, and would only affect the person publishing the package to npm with |
|
Thanks! |
|
@donmccurdy I apologize, I don't think I tested it. No matter how I try to direct import it, it throws errors in browsers. - Uncaught ReferenceError: require is not definedMicrobundle doesn't redefine |
|
It looks like Microbundle expects the input source code to use ES modules. It still creates CJS-compatible outputs from that. I've updated accordingly. For the standalone script use case, this should work: <script src="https://unpkg.com/jsep@0.3.4/build/jsep.js"></script>
<script src="https://unpkg.com/expression-eval@3.0.4/dist/expression-eval.umd.js"></script>
<script>
const fn = expressionEval.compile('a+3');
console.log('result: ', fn({a:4}));
</script> |
|
Awesome, that works great. |
Add UMD (Universal Module) webpacked file for inclusion in plain js projects and automatic inclusion in UNPKG CDN
This would have the added benefit of being able to create codepens etc. for examples and testing.
I also added a basic
example.htmlwhich includes the UMD and lets you test/experiment with it.Note: No modification to
index.js, just added webpack dev-dependency,npm run buildcommand,example.html, and UMD directory/file (maybe eventually add beautified UMDexpression-eval.jsso CDN users can view source in codepens etc.)