Skip to content

Commit

Permalink
fix: update webpack config to use ESM syntax
Browse files Browse the repository at this point in the history
Convert CommonJS module.exports to ESM export default and add proper
type imports. Also add ESM compatible __filename and __dirname
constants using import.meta.
  • Loading branch information
ryoppippi committed Feb 4, 2025
1 parent 6cb5423 commit 4888f24
Showing 1 changed file with 5 additions and 3 deletions.
8 changes: 5 additions & 3 deletions examples/webpack-minimal/webpack.config.ts
Original file line number Diff line number Diff line change
@@ -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: {
Expand Down Expand Up @@ -49,7 +51,7 @@ const config: Configuration = {
},
};

module.exports = () => {
export default () => {
if (isProduction) {
config.mode = 'production';

Expand Down

0 comments on commit 4888f24

Please sign in to comment.