Comments (6)
It is similar to #791 but not really
All cases in #791 point on a missing createRequire
(which BTW seems to work fine now)
My case is that I have require
/ createRequire
but wish to have import
(because what I'm importing is an ESM module)
from ncc.
I am also running into this issue. Running with sourcemaps also gives ReferenceError: __dirname is not defined in ES module scope
. It seems it is still using the global __dirname
which you cannot in ESM.
from ncc.
This sounds like a duplicate of #749
from ncc.
It is not, #749 mentions wanting to output CJS within an ESM module, and it can't access __dirname / __filename
This is issue is about outputing ESM in an ESM module, and importing other ESM modules.
But NCC's transformations tries to require
an ESM module
from ncc.
Oops, I meant duplicate of #791
from ncc.
I think I have the same error. I upgraded a package that required me to update my script to be a module so I could use import. Now I can run the script manually just fine, but once I compile it with ncc and try to run it, it fails
file:///home/chris/workspace/chocrates/actions-governance/dist/exec-child.js:1
if (require.main !== module) {
^
ReferenceError: require is not defined in ES module scope, you can use import instead
This file is being treated as an ES module because it has a '.js' file extension and '/home/chris/workspace/chocrates/actions-governance/dist/package.json' contains "type": "module". To treat it as a CommonJS script, rename it to use the '.cjs' file extension.
at file:///home/chris/workspace/chocrates/actions-governance/dist/exec-child.js:1:1
at ModuleJob.run (node:internal/modules/esm/module_job:192:25)
at async DefaultModuleLoader.import (node:internal/modules/esm/loader:228:24)
at async loadESM (node:internal/process/esm_loader:40:7)
at async handleMainPromise (node:internal/modules/run_main:66:12)
There are no require's in my codebase anymore and it looks like the generated exec-child.js
is the culprit.
from ncc.
Related Issues (20)
- How to include only internal monorepo packages / dependencies? HOT 3
- Incorrect Compilation of Firebase Parameterized Variables by ncc HOT 1
- ncc build fails with bun when node isn't installed
- NCC build fails when compiling a Custom Server NextJS app - ./static.edge is not exported from react-dom HOT 3
- bug TypeError: Cannot read property 'set' of undefined
- Option 'allowImportingTsExtensions' can only be used when either 'noEmit' or 'emitDeclarationOnly' is set. HOT 1
- BUG: Fails to bundle `[email protected]` HOT 1
- How compatible are paths that need to be dynamically loaded at ncc build time HOT 2
- Cannot bundle `@npmcli/arborist` HOT 3
- Java
- Confusing error message "Package path . is not exported from package" HOT 2
- Are there multiple js files in the directory packaged by NCC? HOT 2
- vercel/ncc
- Advantages over other bundlers HOT 4
- more documentation about `--v8-cache`
- ncc and prebuildify HOT 3
- TypeError when resolving symlinked module paths in a Lerna workspace
- 打包之后在linux系统下无法运行 HOT 2
- AssetBuilds repeatedly packages the same resources
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from ncc.