JS - use files meant for <script> in Node

≯℡__Kan透↙ 提交于 2019-12-24 10:51:55

问题


I have used AWS's JS Builder (https://sdk.amazonaws.com/builder/js/) to generate a minified build of only their Lambda SDK. Now I want o use that in a NodeJS-like (specifically ReactJS) environment.

Currently, I am doing so (after referring https://stackoverflow.com/a/49218103/1847976) by adding the said script in the /public/index.html and then accessing the main export (here: AWS) via the window object (as in here window.AWS).

However, are there any issues (specifically compatibility issues) I may face with such a workaround? If yes, is there a way I can directly use the minified JS obtained from AWS's JS Builder in ReactJS? Or is there a totally different method I could I have followed?

P.S.: I have already tried using the in-preview AWS SDK (https://github.com/aws/aws-sdk-js-v3) which will be modularised but faced un-fixable problems (due to which I posted another question here: AWS JS SDK V3 (Lambda module) - Unable to connect to instance metadata service), therefore that is ruled out. I also tried plainly adding the minifed (and unminified) file directly in my React project and importing it but that didn't work either

来源:https://stackoverflow.com/questions/56476748/js-use-files-meant-for-script-in-node

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!