Comments (8)
Let's use this. If problems are still there for we could completely revert things back to 2.3.3 state and publish as 2.4.0
format: context.format === 'commonjs' ? 'commonjs' : 'module',
from esmock.
for now, 2.3.5 is closer to the original 2.3.3 but still gives the 'commonjs' needed for the issue resolved by 2.3.4
// 2.3.3
format: 'module',
// 2.3.4
format: context.format,
// 2.3.5
format: context.format === 'commonjs' ? 'commonjs' : 'module',
from esmock.
Maybe module
could be used as a fallback? e.g.
format: context.format ?? 'module',
from esmock.
Maybe
module
could be used as a fallback? e.g.format: context.format ?? 'module',
Sure, it solves the issue - but not the root cause. Why do we expect anything in 'context.format'? Other loaders / Node default loader may resolve module format, may not. Only esmock has knowledge about files with urls like 'file:///Users/xxxxxxxx/packages/create-request/src/create-request.ts?esmk=1'
PS Yes, I checked my ts-loader - I don't set any format for .ts files if they are imported via relative urls inside 'resolve' hook, it's responsibility of 'load' hook (valid behaviour according to docs). Node default resolver do nothing for .ts file too. And because esmock placed into chain after ts-loader and due to 'shortCircuit: true' here
Line 150 in 35ada4d
ts-loader just have no ability to pass proper format next (== to Node default loader).
from esmock.
oh no I'm sorry everyone
from esmock.
npm won't let me unpublish it
from esmock.
[email protected] is published
from esmock.
@koshic I agree with your comments and am interested to try removing "format" altogether. I don't remember why it is used and it could be something that was used for node 12 or node 14 which esmock did support but there was a problem with npm that forced us to drop node 14 from the test matrix
from esmock.
Related Issues (20)
- Mocking a file with a hashbang using the `import` key fails HOT 7
- Error when using `import` key with modules that have CJS imports HOT 9
- Breakage in Node.js v20.6.0 HOT 18
- `invalid moduleId` in a TypeScript monorepo HOT 35
- yarn pnp issues HOT 14
- Is it possible to mock json imports with assert? HOT 6
- Support Yarn PnP resolver out of the box HOT 11
- Get rid of old Node versions support HOT 8
- resolve error introduced with 2.5.2 HOT 10
- Error when mocking a file that exports an array. HOT 1
- c8 incorrect branch coverage; modules and `import` globals HOT 11
- how to mock globalThis HOT 4
- import('node:fs/promises') called within a library does not seem to be replaced HOT 30
- Path alias support HOT 1
- Unexpected strict mode reserved word syntax error when mocking express HOT 2
- incompatible with eslint-plugin-import HOT 3
- No support for subpath patterns? HOT 14
- Version 2.6.3 changed the way to mock libraries HOT 7
- ESMock seems to wrongfully alter Sinon stubs. HOT 1
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 esmock.