diff --git a/.yarn/sdks/eslint/bin/eslint.js b/.yarn/sdks/eslint/bin/eslint.js index 4d327a49a06d..9ef98e400b47 100755 --- a/.yarn/sdks/eslint/bin/eslint.js +++ b/.yarn/sdks/eslint/bin/eslint.js @@ -1,13 +1,13 @@ #!/usr/bin/env node const {existsSync} = require(`fs`); -const {createRequire, createRequireFromPath} = require(`module`); +const {createRequire} = require(`module`); const {resolve} = require(`path`); const relPnpApiPath = "../../../../.pnp.cjs"; const absPnpApiPath = resolve(__dirname, relPnpApiPath); -const absRequire = (createRequire || createRequireFromPath)(absPnpApiPath); +const absRequire = createRequire(absPnpApiPath); if (existsSync(absPnpApiPath)) { if (!process.versions.pnp) { diff --git a/.yarn/sdks/eslint/lib/api.js b/.yarn/sdks/eslint/lib/api.js index fc728d952bb8..653b22bae06f 100644 --- a/.yarn/sdks/eslint/lib/api.js +++ b/.yarn/sdks/eslint/lib/api.js @@ -1,13 +1,13 @@ #!/usr/bin/env node const {existsSync} = require(`fs`); -const {createRequire, createRequireFromPath} = require(`module`); +const {createRequire} = require(`module`); const {resolve} = require(`path`); const relPnpApiPath = "../../../../.pnp.cjs"; const absPnpApiPath = resolve(__dirname, relPnpApiPath); -const absRequire = (createRequire || createRequireFromPath)(absPnpApiPath); +const absRequire = createRequire(absPnpApiPath); if (existsSync(absPnpApiPath)) { if (!process.versions.pnp) { diff --git a/.yarn/sdks/typescript/bin/tsc b/.yarn/sdks/typescript/bin/tsc index 5608e5743072..454b950b7e8f 100755 --- a/.yarn/sdks/typescript/bin/tsc +++ b/.yarn/sdks/typescript/bin/tsc @@ -1,13 +1,13 @@ #!/usr/bin/env node const {existsSync} = require(`fs`); -const {createRequire, createRequireFromPath} = require(`module`); +const {createRequire} = require(`module`); const {resolve} = require(`path`); const relPnpApiPath = "../../../../.pnp.cjs"; const absPnpApiPath = resolve(__dirname, relPnpApiPath); -const absRequire = (createRequire || createRequireFromPath)(absPnpApiPath); +const absRequire = createRequire(absPnpApiPath); if (existsSync(absPnpApiPath)) { if (!process.versions.pnp) { diff --git a/.yarn/sdks/typescript/bin/tsserver b/.yarn/sdks/typescript/bin/tsserver index cd7d557d523d..d7a605684df9 100755 --- a/.yarn/sdks/typescript/bin/tsserver +++ b/.yarn/sdks/typescript/bin/tsserver @@ -1,13 +1,13 @@ #!/usr/bin/env node const {existsSync} = require(`fs`); -const {createRequire, createRequireFromPath} = require(`module`); +const {createRequire} = require(`module`); const {resolve} = require(`path`); const relPnpApiPath = "../../../../.pnp.cjs"; const absPnpApiPath = resolve(__dirname, relPnpApiPath); -const absRequire = (createRequire || createRequireFromPath)(absPnpApiPath); +const absRequire = createRequire(absPnpApiPath); if (existsSync(absPnpApiPath)) { if (!process.versions.pnp) { diff --git a/.yarn/sdks/typescript/lib/tsc.js b/.yarn/sdks/typescript/lib/tsc.js index 16042d01d4fe..2f62fc96c0a0 100644 --- a/.yarn/sdks/typescript/lib/tsc.js +++ b/.yarn/sdks/typescript/lib/tsc.js @@ -1,13 +1,13 @@ #!/usr/bin/env node const {existsSync} = require(`fs`); -const {createRequire, createRequireFromPath} = require(`module`); +const {createRequire} = require(`module`); const {resolve} = require(`path`); const relPnpApiPath = "../../../../.pnp.cjs"; const absPnpApiPath = resolve(__dirname, relPnpApiPath); -const absRequire = (createRequire || createRequireFromPath)(absPnpApiPath); +const absRequire = createRequire(absPnpApiPath); if (existsSync(absPnpApiPath)) { if (!process.versions.pnp) { diff --git a/.yarn/sdks/typescript/lib/tsserver.js b/.yarn/sdks/typescript/lib/tsserver.js index 9f9f4d6f4696..0fb2ac107978 100644 --- a/.yarn/sdks/typescript/lib/tsserver.js +++ b/.yarn/sdks/typescript/lib/tsserver.js @@ -1,13 +1,13 @@ #!/usr/bin/env node const {existsSync} = require(`fs`); -const {createRequire, createRequireFromPath} = require(`module`); +const {createRequire} = require(`module`); const {resolve} = require(`path`); const relPnpApiPath = "../../../../.pnp.cjs"; const absPnpApiPath = resolve(__dirname, relPnpApiPath); -const absRequire = (createRequire || createRequireFromPath)(absPnpApiPath); +const absRequire = createRequire(absPnpApiPath); const moduleWrapper = tsserver => { if (!process.versions.pnp) { diff --git a/.yarn/sdks/typescript/lib/tsserverlibrary.js b/.yarn/sdks/typescript/lib/tsserverlibrary.js index 878b11946a4c..e7033a81782d 100644 --- a/.yarn/sdks/typescript/lib/tsserverlibrary.js +++ b/.yarn/sdks/typescript/lib/tsserverlibrary.js @@ -1,13 +1,13 @@ #!/usr/bin/env node const {existsSync} = require(`fs`); -const {createRequire, createRequireFromPath} = require(`module`); +const {createRequire} = require(`module`); const {resolve} = require(`path`); const relPnpApiPath = "../../../../.pnp.cjs"; const absPnpApiPath = resolve(__dirname, relPnpApiPath); -const absRequire = (createRequire || createRequireFromPath)(absPnpApiPath); +const absRequire = createRequire(absPnpApiPath); const moduleWrapper = tsserver => { if (!process.versions.pnp) { diff --git a/.yarn/sdks/typescript/lib/typescript.js b/.yarn/sdks/typescript/lib/typescript.js index cbdbf1500fbe..e14fa87beaa4 100644 --- a/.yarn/sdks/typescript/lib/typescript.js +++ b/.yarn/sdks/typescript/lib/typescript.js @@ -1,13 +1,13 @@ #!/usr/bin/env node const {existsSync} = require(`fs`); -const {createRequire, createRequireFromPath} = require(`module`); +const {createRequire} = require(`module`); const {resolve} = require(`path`); const relPnpApiPath = "../../../../.pnp.cjs"; const absPnpApiPath = resolve(__dirname, relPnpApiPath); -const absRequire = (createRequire || createRequireFromPath)(absPnpApiPath); +const absRequire = createRequire(absPnpApiPath); if (existsSync(absPnpApiPath)) { if (!process.versions.pnp) { diff --git a/.yarn/sdks/typescript/package.json b/.yarn/sdks/typescript/package.json index 0f255eef6071..934c5a7ccebf 100644 --- a/.yarn/sdks/typescript/package.json +++ b/.yarn/sdks/typescript/package.json @@ -1,6 +1,6 @@ { "name": "typescript", - "version": "4.7.0-beta-sdk", + "version": "4.8.0-beta-sdk", "main": "./lib/typescript.js", "type": "commonjs" } diff --git a/.yarn/versions/690de515.yml b/.yarn/versions/690de515.yml new file mode 100644 index 000000000000..55d8fd5f41f4 --- /dev/null +++ b/.yarn/versions/690de515.yml @@ -0,0 +1,2 @@ +releases: + "@yarnpkg/sdks": major diff --git a/packages/gatsby/content/advanced/pnpify.md b/packages/gatsby/content/advanced/pnpify.md index 4b584883bcb4..b55e7b629e87 100644 --- a/packages/gatsby/content/advanced/pnpify.md +++ b/packages/gatsby/content/advanced/pnpify.md @@ -11,7 +11,7 @@ description: An overview of PnPify, one of the PnP compatibility layers which em ## Motivation -Plug'n'Play is, by design, compatible with all projects that only make use of the `require` API - whether it's `require`, `require.resolve`, or `createRequireFromPath`. However, some rare projects prefer to reimplement the Node resolution themselves and as such aren't compatible by default with our environment (unless they integrate their resolvers with the [PnP API](/advanced/pnpapi)). +Plug'n'Play is, by design, compatible with all projects that only make use of the `require` API - whether it's `require`, `require.resolve`, or `createRequire`. However, some rare projects prefer to reimplement the Node resolution themselves and as such aren't compatible by default with our environment (unless they integrate their resolvers with the [PnP API](/advanced/pnpapi)). ## PnPify diff --git a/packages/yarnpkg-sdks/sources/generateSdk.ts b/packages/yarnpkg-sdks/sources/generateSdk.ts index d9924652809c..d49343043707 100644 --- a/packages/yarnpkg-sdks/sources/generateSdk.ts +++ b/packages/yarnpkg-sdks/sources/generateSdk.ts @@ -118,13 +118,13 @@ const TEMPLATE = (relPnpApiPath: PortablePath, module: string, {setupEnv = false `#!/usr/bin/env node\n`, `\n`, `const {existsSync} = require(\`fs\`);\n`, - `const {createRequire, createRequireFromPath} = require(\`module\`);\n`, + `const {createRequire} = require(\`module\`);\n`, `const {resolve} = require(\`path\`);\n`, `\n`, `const relPnpApiPath = ${JSON.stringify(npath.fromPortablePath(relPnpApiPath))};\n`, `\n`, `const absPnpApiPath = resolve(__dirname, relPnpApiPath);\n`, - `const absRequire = (createRequire || createRequireFromPath)(absPnpApiPath);\n`, + `const absRequire = createRequire(absPnpApiPath);\n`, `\n`, ...(wrapModule ? [ `const moduleWrapper = ${wrapModule.trim().replace(/^ {4}/gm, ``)}\n`, diff --git a/scripts/test-typescript-patch.js b/scripts/test-typescript-patch.js index ccdb305ac4c0..0cd49f43617f 100644 --- a/scripts/test-typescript-patch.js +++ b/scripts/test-typescript-patch.js @@ -1,4 +1,4 @@ -const {createRequire, createRequireFromPath} = require(`module`); +const {createRequire} = require(`module`); const path = require(`path`); const ts = require(`typescript`); @@ -26,16 +26,12 @@ const TESTS = [ [`@yarnpkg/fslib/sources/index.ts`, `@yarnpkg/fslib`], ]; -const requireFactory = createRequire - ? createRequire - : createRequireFromPath; - for (const [test, expected] of TESTS) { const actual = ts.moduleSpecifiers.getModuleSpecifier( compilerOptions, rootSourceFile, rootSourceFile.fileName, - requireFactory(rootSourceFile.fileName).resolve(test), + createRequire(rootSourceFile.fileName).resolve(test), moduleSpecifierResolutionHost, );