You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I'm writing a JS wrapper library for a Blazor project and I'm stuck trying to use the new JS isolation feature.
The lib I'm wrapping is present in NPM, and prior to JS isolation, I was using Webpack to create my final .js file, which users of my wrapper lib had to include in a <script> tag on their side. It worked fine, but it required users to include a .js file manually.
Fast forward to the .NET 5 release, I would like to use JS isolation so that users no longer need to include a .js file when using my lib. It works fine with simple JS functions, but not when I import ES6 modules. In order to import ES6 modules I need to use Webpack, and I can't figure out how to get a webpacked .js file to work with JS isolation.
As per my webpack config, say my library name is "CoolLib", I should be able to .NET Invoke "CoolFunction" using "CoolLib.CoolFunction". It worked prior to JS isolation, and it doesn't work anymore. How am I supposed to reach CoolFunction at this point?
I tried to make this as clear as possible but it's a rather complex topic for me, sorry!!
reacted with thumbs up emoji reacted with thumbs down emoji reacted with laugh emoji reacted with hooray emoji reacted with confused emoji reacted with heart emoji reacted with rocket emoji reacted with eyes emoji
Uh oh!
There was an error while loading. Please reload this page.
-
I'm writing a JS wrapper library for a Blazor project and I'm stuck trying to use the new JS isolation feature.
The lib I'm wrapping is present in NPM, and prior to JS isolation, I was using Webpack to create my final .js file, which users of my wrapper lib had to include in a <script> tag on their side. It worked fine, but it required users to include a .js file manually.
Fast forward to the .NET 5 release, I would like to use JS isolation so that users no longer need to include a .js file when using my lib. It works fine with simple JS functions, but not when I import ES6 modules. In order to import ES6 modules I need to use Webpack, and I can't figure out how to get a webpacked .js file to work with JS isolation.
As per my webpack config, say my library name is "CoolLib", I should be able to .NET Invoke "CoolFunction" using "CoolLib.CoolFunction". It worked prior to JS isolation, and it doesn't work anymore. How am I supposed to reach CoolFunction at this point?
I tried to make this as clear as possible but it's a rather complex topic for me, sorry!!
Beta Was this translation helpful? Give feedback.
All reactions