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.

Target es6 for esm build

See original GitHub issue

Description of the bug

Previously, I could use postprocessing in my webpack bundling without any additional processing (e.g. babel). Recently, however, it appears the language target has moved to “esnext” which includes language features such as “??” and “?.” which are less compatible. Specifically, the build/postprocessing.esm.js generated file includes these esnext features.

To Reproduce

Run pnpm build and inspect the build/postprocessing.esm.js file to see that it includes ?? and ?. operators.

Expected behavior

Produce a plain “es6” target.

Library versions used

  • Three: n/a
  • Post Processing: main

Potential Solution

The https://github.com/pmndrs/postprocessing/blob/main/esbuild.mjs#L69 instructions do not include target: "es6", but I believe adding this would solve the issue.

Issue Analytics

  • State:closed
  • Created a year ago
  • Comments:7 (2 by maintainers)

github_iconTop GitHub Comments

1reaction
vanruesccommented, Jul 4, 2022

Thanks for the repro 👍

I did some research and found that support for ?? and ?. was added to acorn in version 7. Webpack 4, however, is locked to version 6 and hence doesn’t support this syntax.

You should upgrade to webpack 5 if possible. I’ll set the build target to es2019 which will transpile the ?? and ?. syntax to ease the transition. but this will be reverted in the next major release.

0reactions
canadaduanecommented, Jul 4, 2022

Thanks! I had forgotten that Webpack is dependent on acorn. That was the piece I was missing in being able to explain to myself what was going on.

I believe our project can be updated to Webpack 5, but it will be a few months, so a little more time would be greatly appreciated.

Read more comments on GitHub >

github_iconTop Results From Across the Web

How to transpile ES modules with webpack and Node.js
Learn how webpack interacts with and supports ES modules in this deep dive tutorial on transpilation in Node.js.
Read more >
How to Create a Hybrid NPM Module for ESM and CommonJS.
Author your code in ES6, ES-Next or Typescript using import and export. From this base, you can import either ES modules or CommonJS...
Read more >
Create ES6 module 'equivalent' using webpack output.target ...
The problem. Suppose I have two ES6 files that expose default functions // file_1.js export default function(){ ...
Read more >
Documentation - ECMAScript Modules in Node.js - TypeScript
For the last few years, Node.js has been working to support running ECMAScript modules (ESM). This has been a very difficult feature to...
Read more >
TypeScript and native ESM on Node.js - 2ality
The GitHub repository iterable is an example of a TypeScript ESM package that works on ... "ES6" , "ES2015" : support for 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