diff --git a/.pnp.cjs b/.pnp.cjs index 42137bfe..aaf29201 100755 --- a/.pnp.cjs +++ b/.pnp.cjs @@ -48500,6 +48500,7 @@ function reportRequiredFilesToWatchMode(files) { } function applyPatch(pnpapi, opts) { + const defaultCache = {}; let enableNativeHooks = true; process.versions.pnp = String(pnpapi.VERSIONS.std); const moduleExports = require$$0__default.default; @@ -48519,13 +48520,62 @@ function applyPatch(pnpapi, opts) { } const originalModuleLoad = require$$0.Module._load; require$$0.Module._load = function(request, parent, isMain) { - if (request === `pnpapi`) { - const parentApiPath = opts.manager.getApiPathFromParent(parent); - if (parentApiPath) { - return opts.manager.getApiEntry(parentApiPath, true).instance; + if (!enableNativeHooks) + return originalModuleLoad.call(require$$0.Module, request, parent, isMain); + if (isBuiltinModule(request)) { + try { + enableNativeHooks = false; + return originalModuleLoad.call(require$$0.Module, request, parent, isMain); + } finally { + enableNativeHooks = true; + } + } + const parentApiPath = opts.manager.getApiPathFromParent(parent); + const parentApi = parentApiPath !== null ? opts.manager.getApiEntry(parentApiPath, true).instance : null; + if (parentApi === null) + return originalModuleLoad(request, parent, isMain); + if (request === `pnpapi`) + return parentApi; + const modulePath = require$$0.Module._resolveFilename(request, parent, isMain); + const isOwnedByRuntime = parentApi !== null ? parentApi.findPackageLocator(modulePath) !== null : false; + const moduleApiPath = isOwnedByRuntime ? parentApiPath : opts.manager.findApiPathFor(npath.dirname(modulePath)); + const entry = moduleApiPath !== null ? opts.manager.getApiEntry(moduleApiPath) : { instance: null, cache: defaultCache }; + const cacheEntry = entry.cache[modulePath]; + if (cacheEntry) { + if (cacheEntry.loaded === false && cacheEntry.isLoading !== true) { + try { + cacheEntry.isLoading = true; + if (isMain) { + process.mainModule = cacheEntry; + cacheEntry.id = `.`; + } + cacheEntry.load(modulePath); + } finally { + cacheEntry.isLoading = false; + } + } + return cacheEntry.exports; + } + const module = new require$$0.Module(modulePath, parent != null ? parent : void 0); + module.pnpApiPath = moduleApiPath; + reportRequiredFilesToWatchMode([modulePath]); + entry.cache[modulePath] = module; + if (isMain) { + process.mainModule = module; + module.id = `.`; + } + let hasThrown = true; + try { + module.isLoading = true; + module.load(modulePath); + hasThrown = false; + } finally { + module.isLoading = false; + if (hasThrown) { + delete require$$0.Module._cache[modulePath]; } } - return originalModuleLoad.call(require$$0.Module, request, parent, isMain); + return module.exports; }; function getIssuerSpecsFromPaths(paths) { return paths.map((path) => ({ @@ -48593,7 +48643,7 @@ function applyPatch(pnpapi, opts) { const parentDirectory = (parent == null ? void 0 : parent.filename) != null ? npath.dirname(parent.filename) : null; const absoluteRequest = npath.isAbsolute(request) ? request : parentDirectory !== null ? npath.resolve(parentDirectory, request) : null; if (absoluteRequest !== null) { - const apiPath = parent && parentDirectory === npath.dirname(absoluteRequest) ? opts.manager.getApiPathFromParent(parent) : opts.manager.findApiPathFor(absoluteRequest); + const apiPath = parentDirectory === npath.dirname(absoluteRequest) && (parent == null ? void 0 : parent.pnpApiPath) ? parent.pnpApiPath : opts.manager.findApiPathFor(absoluteRequest); if (apiPath !== null) { issuerSpecs.unshift({ apiPath, @@ -50314,6 +50364,7 @@ function makeManager(pnpapi, opts) { const initialApiStats = opts.fakeFs.statSync(npath.toPortablePath(initialApiPath)); const apiMetadata = /* @__PURE__ */ new Map([ [initialApiPath, { + cache: require$$0.Module._cache, instance: pnpapi, stats: initialApiStats, lastRefreshCheck: Date.now() @@ -50345,6 +50396,7 @@ function makeManager(pnpapi, opts) { } } else { apiMetadata.set(pnpApiPath, apiEntry = { + cache: {}, instance: loadApiInstance(pnpApiPath), stats: opts.fakeFs.statSync(pnpApiPath), lastRefreshCheck: Date.now() @@ -50414,16 +50466,19 @@ ${controlSegment} } while (curr !== PortablePath.root); return addToCacheAndReturn(start, curr, null); } - const moduleToApiPathCache = /* @__PURE__ */ new WeakMap(); function getApiPathFromParent(parent) { if (parent == null) return initialApiPath; - let apiPath = moduleToApiPathCache.get(parent); - if (typeof apiPath !== `undefined`) - return apiPath; - apiPath = parent.filename ? findApiPathFor(parent.filename) : null; - moduleToApiPathCache.set(parent, apiPath); - return apiPath; + if (typeof parent.pnpApiPath === `undefined`) { + if (parent.filename !== null) { + return parent.pnpApiPath = findApiPathFor(parent.filename); + } else { + return initialApiPath; + } + } + if (parent.pnpApiPath !== null) + return parent.pnpApiPath; + return null; } return { getApiPathFromParent, diff --git a/app/examples/react-16/package.json b/app/examples/react-16/package.json index 3820e738..acdaf6ad 100644 --- a/app/examples/react-16/package.json +++ b/app/examples/react-16/package.json @@ -2,7 +2,7 @@ "name": "react-16", "private": true, "scripts": { - "start": "DISABLE_ESLINT_PLUGIN=true react-scripts start" + "dev": "DISABLE_ESLINT_PLUGIN=true PORT=3016 react-scripts start" }, "dependencies": { "@propeldata/ui-kit": "workspace:^", diff --git a/app/examples/react-17/package.json b/app/examples/react-17/package.json index f0f3d43e..75b52aa6 100644 --- a/app/examples/react-17/package.json +++ b/app/examples/react-17/package.json @@ -2,7 +2,7 @@ "name": "react-17", "private": true, "scripts": { - "start": "DISABLE_ESLINT_PLUGIN=true react-scripts start" + "dev": "DISABLE_ESLINT_PLUGIN=true PORT=3017 react-scripts start" }, "dependencies": { "@propeldata/ui-kit": "workspace:^", diff --git a/app/examples/react-18/package.json b/app/examples/react-18/package.json index 84324e2c..ad971636 100644 --- a/app/examples/react-18/package.json +++ b/app/examples/react-18/package.json @@ -2,7 +2,7 @@ "name": "react-18", "private": true, "scripts": { - "start": "DISABLE_ESLINT_PLUGIN=true react-scripts start" + "dev": "DISABLE_ESLINT_PLUGIN=true PORT=3018 react-scripts start" }, "dependencies": { "@propeldata/ui-kit": "workspace:^", diff --git a/package.json b/package.json index 01abbb91..8b0d926a 100644 --- a/package.json +++ b/package.json @@ -9,6 +9,7 @@ ], "nmHoistingLimits": "workspaces", "scripts": { + "examples": "turbo run dev", "build": "turbo run build", "prepare": "yarn build", "lint": "turbo run lint", diff --git a/turbo.json b/turbo.json index f5ada5d1..3343644b 100644 --- a/turbo.json +++ b/turbo.json @@ -10,7 +10,9 @@ "outputs": [] }, "dev": { - "cache": false + "cache": false, + "dependsOn": ["^build"], + "inputs": ["apps/**"] }, "test": { "dependsOn": ["^build"]