From 7ed696c9993f97d479bd3e5742f165f6a3815550 Mon Sep 17 00:00:00 2001 From: ryoppippi <1560508+ryoppippi@users.noreply.github.com> Date: Tue, 4 Feb 2025 12:18:07 +0000 Subject: [PATCH] fix(examples/webpack): update webpack config to use ESM syntax Convert CommonJS module.exports to ESM export default and add proper type imports. Also add ESM compatible __filename and __dirname constants using import.meta. --- examples/webpack-minimal/webpack.config.ts | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/examples/webpack-minimal/webpack.config.ts b/examples/webpack-minimal/webpack.config.ts index 3fd650a0..775328f0 100644 --- a/examples/webpack-minimal/webpack.config.ts +++ b/examples/webpack-minimal/webpack.config.ts @@ -1,16 +1,18 @@ // Generated using webpack-cli https://github.com/webpack/webpack-cli +import type { Configuration } from 'webpack'; import 'webpack-dev-server' import path from 'path'; import HtmlWebpackPlugin from 'html-webpack-plugin'; import WorkboxWebpackPlugin from 'workbox-webpack-plugin'; -import { Configuration } from 'webpack'; import * as tsx from 'tsx/cjs/api' +const __filename = import.meta.filename; +const __dirname = import.meta.dirname; + const {default: UnpluginTypia} = tsx.require('../../packages/unplugin-typia/src/webpack.ts', __filename) const isProduction = process.env.NODE_ENV == 'production'; - const config: Configuration = { entry: './src/index.ts', output: { @@ -49,7 +51,7 @@ const config: Configuration = { }, }; -module.exports = () => { +export default () => { if (isProduction) { config.mode = 'production';