codemod
codemod copied to clipboard
added node.js 22.8.0 codemods
Node.js 22.7.0 → 22.8.0 (Current),
- Link to Official Upgrade Guide: [[Insert Link](https://v3-migration.vuejs.org/)]
enable-compile-cache-in-start-server
- This release adds a new API
module.enableCompileCache()that can be used to enable on-disk code caching of all modules loaded after this API is called. Previously this could only be enabled by theNODE_COMPILE_CACHEenvironment variable, so it could only set by end-users. This API allows tooling and library authors to enable caching of their own code. This is a built-in alternative to the [v8-compile-cache](https://www.npmjs.com/package/v8-compile-cache)/[v8-compile-cache-lib](https://www.npmjs.com/package/v8-compile-cache-lib) packages, but have [better performance](https://github.com/nodejs/node/issues/47472#issuecomment-1970331362) and supports ESM.
Additional Details
- we call
module.enableCompileCache()to enable the compile cache for all modules loaded after this point. - https://go.codemod.com/uufyCK7
vm-context-modifications-codemod
- Node.js implements a flavor of
vm.createContext()and friends that creates a context without contextifying its global object when vm.constants.DONT_CONTEXTIFY is used. This is suitable when users want to freeze the context (impossible when the global is contextified i.e. has interceptors installed) or speed up the global access if they don't need the interceptor behavior.
Additional Details
- The main change introduced in version 22.8.0 is the ability to use
vm.constants.DONT_CONTEXTIFYwhen creating a context - https://go.codemod.com/0kzpXgD
node-script-update-to-experimental-test-coverage
- Node.js now supports requiring code coverage to meet a specific threshold before the process exits successfully. To use this feature, you need to enable the
--experimental-test-coverageflag.
Additional Details
- The
startscript has been modified to include the--experimental-test-coverageflag [4](https://www.knowledgehut.com/blog/web-development/package-json-scripts-node-js). This ensures that code coverage checks are performed every time the application starts. - https://go.codemod.com/VzNlsXE
node-script-start-watch-upgrade
- Starts Node.js in watch mode. When in watch mode, changes in the watched files cause the Node.js process to restart. By default, watch mode will watch the entry point and any required or imported module. Use
--watch-pathto specify what paths to watch.
Additional Details
- We've modified the
"start"script to include--watchflag. - https://go.codemod.com/0TZkjzL
dotenv-to-env-file-migration
- Loads environment variables from a file relative to the current directory, making them available to applications on
process.env. The [environment variables which configure Node.js](https://nodejs.org/api/cli.html#environment-variables), such asNODE_OPTIONS, are parsed and applied. If the same variable is defined in the environment and in the file, the value from the environment takes precedence.
Additional Details
- Previously, the
dotenvpackage was used to load environment variables. - With the new feature, you use the
-env-fileflag to specify the .env file location. - https://go.codemod.com/96u1okG
@dfordp is attempting to deploy a commit to the Codemod Team on Vercel.
A member of the Team first needs to authorize it.