Security News
Research
Data Theft Repackaged: A Case Study in Malicious Wrapper Packages on npm
The Socket Research Team breaks down a malicious wrapper package that uses obfuscation to harvest credentials and exfiltrate sensitive data.
@originjs/vite-plugin-commonjs
Advanced tools
A vite plugin that support commonjs to esm in vite
@originjs/vite-plugin-commonjs is a Vite plugin that allows you to use CommonJS modules in a Vite project. This is particularly useful for integrating legacy code or third-party libraries that are not available as ES modules.
Transform CommonJS to ES Modules
This feature allows you to transform CommonJS modules into ES modules, making it easier to integrate with Vite's modern build system.
import commonjs from '@originjs/vite-plugin-commonjs';
export default {
plugins: [commonjs()]
};
Custom Named Exports
This feature allows you to specify custom named exports for CommonJS modules, which can be useful when the default export behavior does not meet your needs.
import commonjs from '@originjs/vite-plugin-commonjs';
export default {
plugins: [
commonjs({
namedExports: {
'example-package': ['namedExport1', 'namedExport2']
}
})
]
};
Exclude Specific Modules
This feature allows you to exclude specific modules from being transformed, which can be useful if you want to handle certain modules differently.
import commonjs from '@originjs/vite-plugin-commonjs';
export default {
plugins: [
commonjs({
exclude: ['module-to-exclude']
})
]
};
rollup-plugin-commonjs is a Rollup plugin that converts CommonJS modules to ES6, so they can be included in a Rollup bundle. It is similar to @originjs/vite-plugin-commonjs but is designed specifically for Rollup, which Vite uses under the hood.
vite-plugin-require is another Vite plugin that allows you to use CommonJS `require` statements in your Vite project. It is similar to @originjs/vite-plugin-commonjs but focuses more on supporting the `require` syntax rather than full CommonJS module transformation.
Support commonJS to esm in vite
npm install @originjs/vite-plugin-commonjs --save-dev
or
yarn add @originjs/vite-plugin-commonjs --dev
import { viteCommonjs } from '@originjs/vite-plugin-commonjs'
export default {
plugins: [
viteCommonjs()
]
}
exclude: string[]
Dependencies to exclude from transform.
include: string[]
Dependencies that only need to be transform.
import { esbuildCommonjs } from '@originjs/vite-plugin-commonjs'
export default {
optimizeDeps:{
esbuildOptions:{
plugins:[
esbuildCommonjs(['react-calendar','react-date-picker'])
]
}
}
}
include: string[]
Dependent modules need to be transform.FAQs
A vite plugin that support commonjs to esm in vite
The npm package @originjs/vite-plugin-commonjs receives a total of 200,129 weekly downloads. As such, @originjs/vite-plugin-commonjs popularity was classified as popular.
We found that @originjs/vite-plugin-commonjs demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 5 open source maintainers 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.
Security News
Research
The Socket Research Team breaks down a malicious wrapper package that uses obfuscation to harvest credentials and exfiltrate sensitive data.
Research
Security News
Attackers used a malicious npm package typosquatting a popular ESLint plugin to steal sensitive data, execute commands, and exploit developer systems.
Security News
The Ultralytics' PyPI Package was compromised four times in one weekend through GitHub Actions cache poisoning and failure to rotate previously compromised API tokens.