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

Add esm output in build/index.modern.esm.js #2070

Closed
rwv opened this issue Aug 8, 2023 · 3 comments
Closed

Add esm output in build/index.modern.esm.js #2070

rwv opened this issue Aug 8, 2023 · 3 comments
Assignees
Labels
⚡️ Enhancement New feature or request

Comments

@rwv
Copy link

rwv commented Aug 8, 2023

Is your feature request related to a problem? Please describe.
Could you please add esm js file in build folder? ESM enables <script type="module"> in browser and avoid pollute window scope.

Describe the solution you'd like
Use webpack to output an esm file

Describe alternatives you've considered

<script type="module">
import simpleKeyboard from 'https://cdn.jsdelivr.net/npm/simple-keyboard@3.6.40/+esm'
</script>

This is a solution, but I want to enable SRI in my project therefore JsDelivr generated esm might not be suitable for me.

Additional context
Add any other context or screenshots about the feature request here.

@rwv
Copy link
Author

rwv commented Aug 8, 2023

@rwv
Copy link
Author

rwv commented Aug 8, 2023

Another related issue is that when I use

const script=document.createElement("script");
script.src="https://cdn.jsdelivr.net/npm/simple-keyboard@latest/build/index.js";
document.body.appendChild(script);

to create SimpleKeyboard.

The creation seems to conflicts with js-dos (a emscripten project). And window.SimpleKeyboard is undefined even after script.onload. I thought this may be related to some window scope pollution issue and esm may solve this issue.

@hodgef hodgef self-assigned this Aug 14, 2023
@hodgef hodgef added the ⚡️ Enhancement New feature or request label Aug 14, 2023
@hodgef hodgef added this to Acknowledged in ⚡️ Enhancements Aug 21, 2023
@hodgef hodgef closed this as completed in 1019e79 Aug 21, 2023
@hodgef
Copy link
Owner

hodgef commented Aug 21, 2023

Hello @rwv thanks for the suggestion,

I have added index.modern.esm.js to version 3.7.0. Hopefully it does work (it appears Webpack support is experimental at this time). Let me know if you run into any issues.

Regards,
Francisco Hodge

@hodgef hodgef moved this from Acknowledged to Shipped in ⚡️ Enhancements Aug 21, 2023
hodgef added a commit to hodgef/react-simple-keyboard that referenced this issue Aug 21, 2023
hodgef added a commit to simple-keyboard/simple-keyboard-layouts that referenced this issue Aug 21, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
⚡️ Enhancement New feature or request
Projects
Development

No branches or pull requests

2 participants