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.

passive watcher esm module

See original GitHub issue

unbuild uses

await writeFile(output + '.mjs', `${shebang}import jiti from 'jiti';\nexport default jiti(null, { interopDefault: true })('${entry.input}');`)

but this results in

import jiti from 'jiti';
export default jiti(null, { interopDefault: true })('../src/index.ts');

which only do default export for esm modules (not named ones) i tried to figure it out how solve this but seems is not possible what you thing

Issue Analytics

  • State:open
  • Created 2 years ago
  • Reactions:3
  • Comments:9 (1 by maintainers)

github_iconTop GitHub Comments

3reactions
Mr-xzqcommented, Jul 25, 2022

same

2reactions
aphexcommented, Jul 27, 2022

I think what I am seeing is this same issue, originally though it was a jiti problem, but moving details here. I am not sure stubs can currently be used with ESM as trying to use named exports doesn’t work for stubs but using the default export doesn’t work when built.

  1. clone https://github.com/nuxt/framework
  2. run npx yarn install
  3. run npm yarn stub
  4. create test.mjs at the root with contents
import { findPath } from "@nuxt/kit";

console.log(findPath);
  1. run node index.mjs

you will see the error SyntaxError: The requested module '@nuxt/kit' does not provide an export named 'findPath'

Then run npm run build and node index.mjs again you will see findPath resolves fine.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Publish ESM and CJS in a single package - Anthony Fu
A short tutorial of shipping both ESM and CJS dual formats in a single NPM package.
Read more >
ESM Active-Passive High Availability Module Licensing
Starting from ESM 7.2, the Active Passive High Availability (APHA) module requires one or more licenses that enable ESM and the APHA module....
Read more >
unbuild | Yarn - Package Manager
Passive watcher. Stub dist once using jiti and you can try and link your project without needing to watch and rebuild during development....
Read more >
Documentation - ECMAScript Modules in Node.js - TypeScript
Interoperating between the two module systems brings large challenges, with many new features to juggle; however, support for ESM in Node.js is now...
Read more >
Using ECMAScript modules (ESM) with Node.js
Learn about using ES modules in Node.js today and get a closer look at how you can migrate your codebase to make use...
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