Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support Yarn PnP #77

Open
ezracelli opened this issue Jun 30, 2023 · 1 comment
Open

Support Yarn PnP #77

ezracelli opened this issue Jun 30, 2023 · 1 comment
Labels
enhancement ✨ New feature or request

Comments

@ezracelli
Copy link

PnP (a module installation strategy used by Yarn Berry) stores modules in .zip files. When a package is imported, the package manager creates an isolated, read-only virtual filesystem. More info: https://yarnpkg.com/features/pnp

telefunc/vite#plugin has a side-effect that attempts to write to one of telefunc's own files. Due to the read-only nature of the virtual filesystem created by PnP, this write fails.

function plugin(config?: ConfigUser): any {
importGlobOn()

function importGlobOn() {
writeFileSync(

Workaround

I patched the module manually.
diff --git a/dist/cjs/node/vite/importGlob/telefuncFilesGlob.js b/dist/cjs/node/vite/importGlob/telefuncFilesGlob.js
index 12d2beb0902533d560a37205d5c1779a41192d46..a9369b2a79929fd8dc53f02a50bc5d6cf000ae84 100644
--- a/dist/cjs/node/vite/importGlob/telefuncFilesGlob.js
+++ b/dist/cjs/node/vite/importGlob/telefuncFilesGlob.js
@@ -1,4 +1 @@
-"use strict";
-Object.defineProperty(exports, "__esModule", { value: true });
-exports.importGlobUnset = void 0;
-exports.importGlobUnset = true;
+export const telefuncFilesGlob = import.meta.glob("/**/*.telefunc.(js|cjs|mjs|ts|cts|mts|jsx|cjsx|mjsx|tsx|ctsx|mtsx)");
diff --git a/dist/cjs/node/vite/index.js b/dist/cjs/node/vite/index.js
index dd988d6ee4dd2dd361d5461df11d9742ab18b940..83523a7ccfadf5486f2899699dcd4ac3ba55c1e3 100644
--- a/dist/cjs/node/vite/index.js
+++ b/dist/cjs/node/vite/index.js
@@ -12,10 +12,8 @@ const importBuild_1 = require("./plugins/importBuild");
 const previewConfig_1 = require("./plugins/previewConfig");
 const printShieldGenResult_1 = require("./plugins/printShieldGenResult");
 const manifest_1 = require("./plugins/manifest");
-const toggle_1 = require("./importGlob/toggle");
 // Return as `any` to avoid Plugin type mismatches when there are multiple Vite versions installed
 function plugin(config) {
-    (0, toggle_1.importGlobOn)();
     const plugins = [
         (0, transform_1.transform)(),
         (0, commonConfig_1.commonConfig)(),
@brillout brillout changed the title Vite plugin is incompatible with PnP Support Yarn PnP Jul 1, 2023
@brillout brillout added the enhancement ✨ New feature or request label Jul 1, 2023
@brillout
Copy link
Owner

brillout commented Jul 1, 2023

Indeed. FYI the side-effect will be removed soon. In the meantime use pnpm (recommended) or npm instead.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement ✨ New feature or request
Projects
None yet
Development

No branches or pull requests

2 participants