
Product
Socket Firewall Now Blocks Malicious VS Code and Open VSX Extensions
Socket Firewall blocks malicious VS Code and Open VSX extensions before install, protecting developers from compromised editor marketplaces.
umd-package-loader
Advanced tools
tnpm i umd-package-loader --save
import Loader from 'umd-package-loader';
const LazyLoadComponent = (): JSX.Element => {
const [com, setCom] = React.useState(null)
React.useEffect(() => {
new Loader({
url: 'https://xxx.js',
name: 'xxx', // library name e.g. xxxCom
}).loadScript().then(component => {
const node = component.default;
setCom(React.createElement(node))
}).catch(err => {
// dosomething
})
}, []);
return com
}
support requirejs,When the page has requirejs, it will be loaded in the way of require.if not, will use document.createElement('script') load script.
be careful, must follow commonjs or amd standard, forever, umd better. e.g. webpack config
module.exports = {
devtool: 'source-map',
entry: {
reactDemo: resolve(__dirname, '../appGrounds/react/index.tsx')
},
output: {
library: "xxxCom", // moduleName, the loader prop
libraryTarget: 'umd', // must
filename: '[name].js',
path: resolve(__dirname, '../entry/lib'),
}
}
MIT
FAQs
umd 包加载器
We found that umd-package-loader demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Product
Socket Firewall blocks malicious VS Code and Open VSX extensions before install, protecting developers from compromised editor marketplaces.

Research
More than 140 Mastra npm packages were compromised in a supply chain attack that used a typosquatted dependency to deliver a cross-platform infostealer during installation.

Research
/Security News
A new npm package tests AI malware scanners with prompt injection, safety-triggering comments, context flooding, and obfuscated JavaScript.