Security News
The Unpaid Backbone of Open Source: Solo Maintainers Face Increasing Security Demands
Solo open source maintainers face burnout and security challenges, with 60% unpaid and 60% considering quitting.
@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 161,381 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
Solo open source maintainers face burnout and security challenges, with 60% unpaid and 60% considering quitting.
Security News
License exceptions modify the terms of open source licenses, impacting how software can be used, modified, and distributed. Developers should be aware of the legal implications of these exceptions.
Security News
A developer is accusing Tencent of violating the GPL by modifying a Python utility and changing its license to BSD, highlighting the importance of copyleft compliance.