Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

150
Views
Configuring WebPack for Typescript with import

The tutorial of webpack configuration for typescript shows something like this:

const path = require('path');

module.exports = { ... }

Would it not be better to use it as es module and configure it with e.g. imports. Or is there a reason why it is configured like above? I cant find any example where it is configured like this:

import webpack from "webpack";
import path from "path";

export default () => { ... }
about 4 years ago · Juan Pablo Isaza
1 answers
Answer question

0

TypeScript and the newer ES standard are supersets of normal JavaScript. Writing config files using widely supported syntax and features makes it more widely available and acceptable without requiring additional setup.

TypeScript is a better practice in some ways, but you need to introduce extra dependencies and configuration to use it, in some organizations you don't even have that freedom. Similar to ES, Node.js didn't have native support for mjs until v12.

The good news is that Webpack also supports writing configurations in multiple languages including TypeScript, see https://webpack.js.org/configuration/configuration-languages/

It's also available to get features like IntelliSense by using TypeScript JSDoc annotations if for some reason you can't write TypeScript directly:

/** @type { import('webpack').Configuration } */
const config = {...};
module.exports = config;
about 4 years ago · Juan Pablo Isaza Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!