Research
Security News
Quasar RAT Disguised as an npm Package for Detecting Vulnerabilities in Ethereum Smart Contracts
Socket researchers uncover a malicious npm package posing as a tool for detecting vulnerabilities in Etherium smart contracts.
esbuild + post builds(copy files, inject html, run static server, and watch files)
bojagi is a a traditional Korean wrapping cloth for books, gifts, etc.
$ npm i bojagi -D
$ bojagi build
$ bojagi serve
$ bojagi <section> # any section in bojagi.config.js
const bojagi = require('bojagi');
bojagi.build(options).then(esbuildResult => {
...
})
all esbuild options are allowed, https://esbuild.github.io/api/#build-api.
preBuilds: an array of function to run before esbuild.build() Example
module.exports = {
build: {
entryPoints: ['src/main.js'],
entryNames: '[name]-[hash]',
outdir: 'dist',
bundle: true,
...
preBuilds: [ function clear() {rimraf('dist')} ],
...
}
}
postBuilds: an array of function to run after esbuild.build().
a post build function takes two parameters internally
module.exports = {
build: {
entryPoints: ['src/main.js'],
entryNames: '[name]-[hash]',
outdir: 'dist',
bundle: true,
...
postBuilds: [
function(options, buildResult) { // run a websocket server
const wss = new WebSocketServer({ port: 8081});
wss.on('connection', socket => wsClients.push(socket));
}
]
}
}
A full example can be found here. https://github.com/elements-x/elements-x/blob/master/bojagi.config.js
esbuild plugin that minify css and html
src/main.js
import html from './test.html';
import css from './test.css';
console.log(html + css);
Example
const bojagi = require('bojagi');
const { minifyCssPlugin, minifyHtmlPlugin } = bojagi.esbuildPlugins;
const options = {
entryPoints: ['src/main.js'],
plugins: [minifyCssPlugin, minifyHtmlPlugin]
};
bojagi.build(options).then(esbuildResult => {
...
});
copy files to a directory by replacing file contents
Example
const bojagi = require('bojagi');
const {copy} = bojagi.postBuilds
const options = {
entryPoints: ['src/main.js']
postBuilds: [
copy('src/**/!(*.js) public/* dist', {
replacements: [ {match: /index\.html/, find: /FOO/, replace: 'BAR'} ]
})
]
}
bojagi.build(options).then(esbuildResult => {
...
})
Inject esbuild compile output to index.html.
e.g.
<!-- your index.html -->
<script src="main.js"></script>
<link rel="stylesheet" href="style.css" />
</body>
</html>
Example
const bojagi = require('bojagi');
const {injectEsbuildResult} = bojagi.postBuilds;
const options = {
entryPoints: ['src/main.js']
postBuilds: [ injectEsbuildResult() ]
}
bojagi.build(options).then(esbuildResult => {
...
})
Run a static http server for a given directory. Two parameters accepted
require('memfs')
. Default require('fs')
.{match: /.*$/, serve: path.join(dir, 'index.html')}
Example
const bojagi = require('bojagi');
const {runStaticServer} = bojagi.postBuilds;
const options = {
entryPoints: ['src/main.js']
postBuilds: [
runStaticServer('src', {
fs: require('memfs'),
port: 9100,
notFound: {match: /.*$/, serve: path.join(dir, 'index.html')
}})
]
}
bojagi.build(options).then(esbuildResult => {
...
})
Watch the given directory, and rebuild and reload when a file change happens It also statts a websocket server to reload browser client when file change happens.
Parameters:
Example
const bojagi = require('bojagi');
const {watchAndReload} = bojagi.postBuilds;
const options = {
entryPoints: ['src/main.js']
postBuilds: [
watchAndReload('src', 9110)
]
}
bojagi.build(options).then(esbuildResult => {
...
})
FAQs
esbuild + post builds(copy files, inject html, run static server, and watch files)
The npm package bojagi receives a total of 0 weekly downloads. As such, bojagi popularity was classified as not popular.
We found that bojagi 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.
Research
Security News
Socket researchers uncover a malicious npm package posing as a tool for detecting vulnerabilities in Etherium smart contracts.
Security News
Research
A supply chain attack on Rspack's npm packages injected cryptomining malware, potentially impacting thousands of developers.
Research
Security News
Socket researchers discovered a malware campaign on npm delivering the Skuld infostealer via typosquatted packages, exposing sensitive data.