Solving Next.js v16 auto-import: Introducing webpack loader-based auto-import-x-loader
## Background
Previously, I was using unplugin-auto-import in Next.js through a webpack plugin. However, since Next.js v16, webpack plugins are no longer supported, and turbopack doesn't support the plugin mechanism yet, but it does support [webpack loaders](https://nextjs.org/docs/app/api-reference/config/next-config-js/turbopack#missing-webpack-loader-features).
### Implementation
Thanks to the well-encapsulated underlying capabilities of [unimport](https://github.com/unjs/unimport), implementing a webpack loader wasn't too difficult. This allows for a smoother upgrade to Next.js v16.
Source code: [auto-import-x-loader](https://github.com/yunsii/awesome-exhibition/tree/main/packages/auto-import-loader)
1 条评论