Comments (13)
Okay, there are two things to learn from this: don't import internal paths (./lib
), and release ESM support as a breaking change, always.
Why does this happen?
You're using an old version of msw
that depends on the old version of @mswjs/interceptors
, which, in turn, has headers-polyfill/lib
imports in its source. Since the interceptors pull the latest 3.x
headers-polyfill
, you get a package that has an explicit "exports" map where there's no ./lib
export defined, causing the compilation error.
How do I fix this?
Update the msw
version you're using. The original report above uses [email protected]
which is an extremely old version.
npm i msw@latest --save-dev
You will get [email protected]
(at the moment of writing this) and @mswjs/[email protected]
, which doesn't import the ./lib
path anymore.
from headers-polyfill.
@TimClmd you probably try resolutions, it works for me.
"resolutions": {
"headers-polyfill": "3.0.10"
}
from headers-polyfill.
Hacky solution for npm projects referencing version 3.1.0:
Modify the headers-polyfill package.json
"exports"
to include the subpath "./lib"
, pointing it to the index "./lib/index.js"
:
{
"name": "headers-polyfill",
"version": "3.1.0",
"description": "A native \"Headers\" class polyfill.",
"main": "./lib/index.js",
"module": "./lib/esm/index.js",
"types": "./lib/index.d.ts",
"exports": {
".": {
"types": "./lib/index.d.ts",
"require": "./lib/index.js",
"default": "./lib/esm/index.js"
},
"./lib": "./lib/index.js"
},
"repository": "https://github.com/mswjs/headers-polyfill",
"author": "Artem Zakharchenko",
"license": "MIT",
"scripts": {
"start": "tsup --watch",
"clean": "rimraf lib",
"build": "yarn clean && tsup",
"test": "jest",
"release": "release publish",
"prepublishOnly": "yarn test && yarn build"
},
"files": [
"lib",
"README.md"
],
"devDependencies": {
"@ossjs/release": "^0.3.0",
"@types/jest": "^28.1.4",
"jest": "^28.1.2",
"jest-environment-jsdom": "^28.1.2",
"rimraf": "^3.0.2",
"ts-jest": "^28.0.5",
"tsup": "^6.2.3",
"typescript": "4.3.2"
}
}
from headers-polyfill.
@johnfrommartin Please reference this issue in your PR so it'll get resolved.
from headers-polyfill.
Thanks for reporting this. We need to get rid of /lib
imports in @mswjs/interceptors
.
from headers-polyfill.
Thanks for reporting this. We need to get rid of
/lib
imports in@mswjs/interceptors
.
Do you have an ETA on when this will be fixed? We're seeing the same issue and reverting to previously-working version of mswjs does not fix as it's still pulling in version 3.1.2 here:
node_modules@mswjs\interceptors\node_modules\headers-polyfill
from headers-polyfill.
reverting to previously-working version of mswjs does not fix as it's still pulling in version
Had the same issue, you can just install [email protected]
in your package.json until a fix comes through and it should resolve the issue. @TimClmd
from headers-polyfill.
reverting to previously-working version of mswjs does not fix as it's still pulling in version
Had the same issue, you can just install
[email protected]
in your package.json until a fix comes through and it should resolve the issue. @TimClmd
@DeclanBoller Thanks, yep I tried exactly this - it installed the correct version of headers-polyfill in the project's main node_modules folder, but mswjs still installed the newer version in its own node_modules folder as described, and this is what mswjs ends up using. Without mwjs's own package.json limiting the version, I'm not sure if it's possible to restrict this - is there a trick I don't know about to achieve this (searching on it, I'm not seeing a ton though it might just be I can't figure out how to ask the question right...)?
from headers-polyfill.
YES, thank you. That worked and gets us unstuck pending official resolution.
from headers-polyfill.
@TimClmd you probably try resolutions, it works for me.
"resolutions": { "headers-polyfill": "3.0.10" }
Just a heads up for anyone else finding this workaround, resolutions
is a Yarn feature and doesn't work with npm.
from headers-polyfill.
Just a heads up for anyone else finding this workaround, resolutions is a Yarn feature and doesn't work with npm
NPM users on v8 can use overrides
to the same effect
https://docs.npmjs.com/cli/v8/configuring-npm/package-json#overrides
npm ls headers-polyfill
to verify the override is applied.
from headers-polyfill.
Created a PR to fix this, adding './lib' as an export subpath here.
from headers-polyfill.
@johnfrommartin Please reference this issue in your PR so it'll get resolved.
@acdvs Done
from headers-polyfill.
Related Issues (20)
- License? HOT 2
- Keep private properties under symbols HOT 1
- Invalid Headers.js syntax ? HOT 8
- Package subpath './lib' is not defined by "exports" HOT 3
- Missing "./lib" export in "headers-polyfill" package HOT 2
- Version 3.1.0 => Error: Package subpath './lib' is not defined by "exports" HOT 6
- Error: Package path ./lib is not exported from package HOT 1
- There's no lib folder which is called from /esm/package.json HOT 1
- Webpack compilation error after update HOT 4
- The module does not support ESM correctly HOT 1
- "flattenHeadersObject" joins multi-value headers but semicolon, not comma HOT 1
- Package subpath './lib' is not defined by "exports" HOT 3
- Cypress: Unexpected token on nullish coalescence operator HOT 12
- Nullish coalescing operator (??) causing webpack build to fail HOT 2
- 3.2.0 does not handle Set-Cookie as expected HOT 2
- Can't import the named export 'splitCookiesString' HOT 7
- Move custom Headers methods to transformer functions HOT 1
- response3.headers.all is not a function HOT 4
- Losing headers when using Undici in latest Node 18.x HOT 3
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 headers-polyfill.