Version 2.0.0 introduces breaking changes due to structural improvements and Webpack support. Follow these steps to ensure a smooth upgrade.
Install the latest version of ts-runtime-picker:
npm install ts-runtime-picker@2.0.0The import name for the Vite plugin has changed:
- Before:
import tsRuntimePicker from "ts-runtime-picker/vite-plugin";
- Now:
Update your
import TsRuntimePickerVitePlugin from "ts-runtime-picker/vite-plugin";
vite.config.tsto reflect the new import name:import { defineConfig } from "vite"; import TsRuntimePickerVitePlugin from "ts-runtime-picker/vite-plugin"; export default defineConfig({ plugins: [TsRuntimePickerVitePlugin()], });
For projects using Webpack, you can now integrate ts-runtime-picker using its custom loader.
-
Update Webpack Configuration: Add the following rule to your
webpack.config.js:{ test: /\.ts$/, use: [ { loader: 'ts-loader', }, { loader: 'ts-runtime-picker/webpack-loader', // ts-runtime-picker loader }, ], }
-
Ensure the Order of Loaders: The
ts-runtime-picker/webpack-loadermust come afterts-loaderto work correctly.
After upgrading, rebuild your project and verify that:
- Your Vite or Webpack configurations are correctly updated.
- Your
createPickercalls are being transformed as expected.
-
Vite Plugin Errors:
- Ensure you’ve updated the import to
TsRuntimePickerVitePlugin.
- Ensure you’ve updated the import to
-
Webpack Loader Issues:
- Ensure the loader is placed after
ts-loaderin your Webpack rules. - Verify that your TypeScript files are correctly matched by the
testcondition.
- Ensure the loader is placed after
By following these steps, your project will be fully compatible with the new version of ts-runtime-picker. 🚀 Let us know if you encounter any issues!