question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Support ESM applications and configs

See original GitHub issue

this package cannot be used with es modules (i.e packages that have type: module)

in this line you are using require() to load the custom webpack config file. if custom.webpack.config.ts is inside an es module, you must use import()

// should be replaced with `import(path)`
  const customWebpackConfig = require(path);

also it has to handle webpack.config that written in typescript i.e custom.webpack.ts you will need to pass --experimental-specifier-resolution=node to ts-node, so it can work with .ts

I use Angular v13 and custom-webpack v13

minimal reproduction run ng build

Issue Analytics

  • State:closed
  • Created 2 years ago
  • Comments:30 (13 by maintainers)

github_iconTop GitHub Comments

1reaction
eng-dibocommented, Jan 26, 2022

why would you need "type": "module" in an Angular app? Just curious.

  1. your project may include other stuff than Angular. Angular itself doesn’t force switching to esm, but other situations may be involved.
  2. you may depend on esm packages that don’t compatible with commonjs (using condition exports for example)
  3. you may need to get benefits from migrating to esm, like using imports to enable path aliasing natively
1reaction
just-jebcommented, Jan 25, 2022

It is an existing feature, no need to add it, just need to support ESM.
The reasons for its existence are mostly historical. Originally index.html was being generated as part of the webpack build and at some point it had been separated into a stand alone process that runs after the webpack build, but still as part of the build-angular builders.
Since it’s performed in the same builder in Angular CLI, you can’t really separate this functionality into a separate builder.
Maybe if they switch it to multiple aggregated builders later on we’ll revise it again.

I like to think of it as a repurposing of custom-webpack builder. In this context custom-webpack builder is not just a Custom Webpack builder, it’s more like extended-angular-builder, which has the functionality of webpack config modification and indexTransform.

Although semantics is important I don’t think it’s a good enough reason to rename the package 😅

Read more comments on GitHub >

github_iconTop Results From Across the Web

What does it take to support Node.js ESM? – The Guild
I have worked on all The Guild's libraries and graphql-js to support ESM. Here is how you can do it too.
Read more >
Getting Started with (and Surviving) Node.js ESM
The Node.js ecosystem is shifting towards ESM. We examine what lies in store for application and library authors, learn some of challenges ...
Read more >
Support ESM Syntax in config files · Issue #509 - GitHub
Config files need to be written in node-commonjs-style (no import ... or export const ... Change the setup so that ESM syntax is...
Read more >
Use the Node.js agent with ESM - Contrast Documentation
The Contrast Node.js agent provides limited support for using ECMAScript modules (ESM) in Node.js server-side applications.
Read more >
Extended Security Maintenance (ESM) - Ubuntu
Extended Security Maintenance provides ongoing Linux security fixes for Ubuntu for the Linux kernel and essential packages beyond the five-year basic ...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found