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.

Export clean ESM modules

See original GitHub issue

Using graphql@14.2.1

/node_modules/graphql/jsutils/instanceOf.mjs line 16

// See: https://expressjs.com/en/advanced/best-practice-performance.html#set-node_env-to-production
// See: https://webpack.js.org/guides/production/
export default process.env.NODE_ENV === 'production' ? // eslint-disable-next-line no-shadow
Uncaught ReferenceError: process is not defined
    at instanceOf.mjs:16

The check process.env.NODE_ENV === 'production' breaks in the browser when using ESM version of graphql package. Is it possible to remove before publishing to NPM? Without it the ESM files work perfectly.

I am not using Webpack/RollUp/Babel. Simply copying the ESM files from node_modules to my frontend folder using unbundle.

Related but different:

Issue Analytics

  • State:closed
  • Created 4 years ago
  • Reactions:5
  • Comments:12 (1 by maintainers)

github_iconTop GitHub Comments

1reaction
Banou26commented, Jan 5, 2020

Could the ESM exports use complete import paths ? e.g

- export { Source } from './source';
+ export { Source } from './source.mjs';

Since this results in errors like

Error: Cannot find module C:\dev\oz\packages\api\node_modules\graphql\language\source imported from C:\dev\oz\packages\api\node_modules\graphql\language\index.mjs

when using nodejs with ESM

0reactions
IvanGoncharovcommented, Feb 10, 2020

Released as 15.0.0-rc.2. Last remaining issue tracked here: #2409

Read more comments on GitHub >

github_iconTop Results From Across the Web

ECMAScript modules | Node.js v19.3.0 Documentation
Modules are defined using a variety of import and export statements. The following example of an ES module exports a function:
Read more >
ECMAScript Modules - webpack
Webpack supports processing ECMAScript Modules to optimize them. Exporting. The export keyword allows to expose things from an ESM to other modules:
Read more >
CommonJS vs. ES Modules: Modules and Imports in NodeJS
Export with ES Modules​​ Instead of the require() function for importing modules, we now use a specific import syntax. Also, instead of a ......
Read more >
What does it take to support Node.js ESM? – The Guild
exports is available, and since support for Node.js v10.x is dropped, everything should be fine and supporting ESM shouldn't be that hard. After ......
Read more >
Building CJS module from ESM with mixed named and default ...
A default export is a named export, it's just named default . ESM is built so that if you don't specify a name,...
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