You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
The famous PnP microsoft/TypeScript#35206 introduces a getPnpApi() function which does a require("module") to help determine if PnP is present.
When using with https://vitejs.dev/ in the browser (yes I'm running the Typescript compiler in the browser, which works just fine with Webpack 4), the result of require("module") is a Proxy object which blows up if you touch it. This is a problem.
Here is what I have done to the patched version in typescript.js which works:
function getPnpApi(path) {
var m;
try {
m = require("module");
} catch (error) {
}
if (typeof m?.findPnpApi !== 'function') {
return undefined;
}
var findPnpApi = m.findPnpApi;
if (findPnpApi === undefined) {
return undefined;
}
return findPnpApi("".concat(path, "/"));
}
In addition, I changed my vite.config.js to exclude module, but it's unclear that that's really necessary.
FYI - Vite uses esbuild for yarn start and Rollup for the production build.
To reproduce
Use the Typescript compiler in the browser and Vite to bundle it. Do a yarn start, and it will get an error at runtime.
This issue looks stale, and doesn't feature the reproducible label - which implies that you didn't provide a working reproduction using Sherlock. As a result, it'll be closed in a few days unless a maintainer explicitly vouches for it or you edit your first post to include a formal reproduction (you can use the playground for that).
Note that we require Sherlock reproductions for long-lived issues (rather than standalone git repositories or similar) because we're a small team. Sherlock gives us the ability to check which bugs are still affecting the master branch at any given point, and decreases the amount of code we need to run on our own machines (thus leading to faster bug resolutions). It helps us help you! 😃
If you absolutely cannot reproduce a bug on Sherlock (for example because it's a Windows-only issue), a maintainer will have to manually add the upholded label. Thanks for helping us triaging our repository! 🌟
Ran into this issue when bundling patched TypeScript for the browser with Webpack 4 and was forced to switch to a -dev version (which yarn doesn't have a patch for). Maybe we could have an option to opt out of the patch for now?
Self-service
Describe the bug
The famous PnP microsoft/TypeScript#35206 introduces a
getPnpApi()
function which does arequire("module")
to help determine if PnP is present.When using with https://vitejs.dev/ in the browser (yes I'm running the Typescript compiler in the browser, which works just fine with Webpack 4), the result of
require("module")
is aProxy
object which blows up if you touch it. This is a problem.Here is what I have done to the patched version in typescript.js which works:
In addition, I changed my vite.config.js to exclude
module
, but it's unclear that that's really necessary.FYI - Vite uses esbuild for yarn start and Rollup for the production build.
To reproduce
Use the Typescript compiler in the browser and Vite to bundle it. Do a yarn start, and it will get an error at runtime.
Environment
System: OS: macOS 12.1 CPU: (12) x64 Intel(R) Core(TM) i7-8850H CPU @ 2.60GHz Binaries: Node: 14.17.3 - /private/var/folders/s7/1ndbqwz50xd84b32lkmj97900000gn/T/xfs-1f0ffe89/node Yarn: 3.1.1 - /private/var/folders/s7/1ndbqwz50xd84b32lkmj97900000gn/T/xfs-1f0ffe89/yarn npm: 8.1.0 - ~/.nvm/versions/node/v14.17.3/bin/npm
Additional context
No response
The text was updated successfully, but these errors were encountered: