-
Notifications
You must be signed in to change notification settings - Fork 45
Minimal implementation for umd #106
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
Conversation
is this the proper way to implement UMD? anyhow, I still can't seem to import anything like that. no edit: footer: {
js: 'export default SolidityParser;',
}, I can open a PR if you let me know this is the acceptable approach. |
@hananbeer your solution only works for This implementation is closest to this example with some tweaks that allow for environments implementing different global namespaces like I have tested the built in an ESM project and you can import it: // instead of
import { parse } from '@solidity-parser/parser';
parse(...)
// like this
import parser from '@solidity-parser/parser';
parser.parse(...) I'll investigate why the first option doesn't work, but using the second one, this format works for browsers and node. |
After some investigation, import { parse } from '@solidity-parser/parser'; does not work because it depends on a named import parser from '@solidity-parser/parser';
const { parse } = parser; |
actually I loaded the output directly inside a script tag, no webpack after esbuild: <script type="module">
import SolidityParser from './index.iife.js'
console.log(SolidityParser.parse)
</script> whereas using your branch for UMD throws an error: <script type="module">
import parser from './index.umd.js'
console.log(parser.parse)
</script>
let me know if I'm doing anything wrong.. btw generally speaking I don't see UMD as so popular or favorable, despite the name. |
Can you try: <script src="./index.umd.js"></script>
<script>
console.log(SolidityParser);
</script> |
ah right. that makes sense. I did that because my react code does |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Super minor bikeshedding comment to pretend I was useful. Feel free to merge with or without it.
Co-authored-by: Franco Victorio <victorio.franco@gmail.com>
closes #47