diff --git a/e2e-tests/contentful/cypress/integration/engines.js b/e2e-tests/contentful/cypress/integration/engines.js new file mode 100644 index 0000000000000..e68b27dcda88a --- /dev/null +++ b/e2e-tests/contentful/cypress/integration/engines.js @@ -0,0 +1,11 @@ +describe(`Engines (SSR)`, () => { + beforeEach(() => { + cy.visit("/ssr").waitForRouteChange() + }) + it(`should work`, () => { + cy.get('[data-cy-id="getserverdata-result"]').should( + "have.text", + "getServerData used in contentful E2E test" + ) + }) +}) diff --git a/e2e-tests/contentful/src/pages/ssr.js b/e2e-tests/contentful/src/pages/ssr.js new file mode 100644 index 0000000000000..c9e4a0c83769a --- /dev/null +++ b/e2e-tests/contentful/src/pages/ssr.js @@ -0,0 +1,18 @@ +import React from "react" +import Layout from "../components/layout" + +const SSRPage = ({ serverData }) => ( + +
{serverData.test}
+
+) + +export default SSRPage + +export function getServerData() { + return { + props: { + test: "getServerData used in contentful E2E test", + }, + } +} diff --git a/package.json b/package.json index 70e5de7ea8fc5..bb303b4cf30cd 100644 --- a/package.json +++ b/package.json @@ -127,5 +127,8 @@ }, "workspaces": [ "packages/*" - ] + ], + "resolutions": { + "@babel/plugin-transform-modules-commonjs": "7.18.6" + } } diff --git a/packages/babel-preset-gatsby-package/lib/__tests__/fixtures/keep-dynamic-import/default/output.js b/packages/babel-preset-gatsby-package/lib/__tests__/fixtures/keep-dynamic-import/default/output.js index f4449b7902cd6..1893c46fea3d6 100644 --- a/packages/babel-preset-gatsby-package/lib/__tests__/fixtures/keep-dynamic-import/default/output.js +++ b/packages/babel-preset-gatsby-package/lib/__tests__/fixtures/keep-dynamic-import/default/output.js @@ -5,5 +5,5 @@ exports.someFunction = someFunction; function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "function") return null; var cacheBabelInterop = new WeakMap(); var cacheNodeInterop = new WeakMap(); return (_getRequireWildcardCache = function (nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); } function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null || typeof obj !== "object" && typeof obj !== "function") { return { default: obj }; } var cache = _getRequireWildcardCache(nodeInterop); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj.default = obj; if (cache) { cache.set(obj, newObj); } return newObj; } async function someFunction() { - return await (specifier => new Promise(r => r(specifier)).then(s => _interopRequireWildcard(require(s))))(`path`); + return await Promise.resolve().then(() => _interopRequireWildcard(require(`path`))); } diff --git a/yarn.lock b/yarn.lock index 1ca3451d8df11..9691e06e02ec8 100644 --- a/yarn.lock +++ b/yarn.lock @@ -483,7 +483,7 @@ "@babel/traverse" "^7.20.7" "@babel/types" "^7.20.7" -"@babel/helper-simple-access@^7.20.2": +"@babel/helper-simple-access@^7.18.6", "@babel/helper-simple-access@^7.20.2": version "7.20.2" resolved "https://registry.yarnpkg.com/@babel/helper-simple-access/-/helper-simple-access-7.20.2.tgz#0ab452687fe0c2cfb1e2b9e0015de07fc2d62dd9" integrity sha512-+0woI/WPq59IrqDYbVGfshjT5Dmk/nnbdpcF8SnMhhXObpTq2KNBdLFRFrkVdbDOyUmHBCxzm5FHV1rACIkIbA== @@ -1018,14 +1018,15 @@ "@babel/helper-module-transforms" "^7.20.11" "@babel/helper-plugin-utils" "^7.20.2" -"@babel/plugin-transform-modules-commonjs@^7.0.0", "@babel/plugin-transform-modules-commonjs@^7.13.8", "@babel/plugin-transform-modules-commonjs@^7.19.6", "@babel/plugin-transform-modules-commonjs@^7.20.11": - version "7.20.11" - resolved "https://registry.yarnpkg.com/@babel/plugin-transform-modules-commonjs/-/plugin-transform-modules-commonjs-7.20.11.tgz#8cb23010869bf7669fd4b3098598b6b2be6dc607" - integrity sha512-S8e1f7WQ7cimJQ51JkAaDrEtohVEitXjgCGAS2N8S31Y42E+kWwfSz83LYz57QdBm7q9diARVqanIaH2oVgQnw== +"@babel/plugin-transform-modules-commonjs@7.18.6", "@babel/plugin-transform-modules-commonjs@^7.0.0", "@babel/plugin-transform-modules-commonjs@^7.13.8", "@babel/plugin-transform-modules-commonjs@^7.19.6", "@babel/plugin-transform-modules-commonjs@^7.20.11": + version "7.18.6" + resolved "https://registry.yarnpkg.com/@babel/plugin-transform-modules-commonjs/-/plugin-transform-modules-commonjs-7.18.6.tgz#afd243afba166cca69892e24a8fd8c9f2ca87883" + integrity sha512-Qfv2ZOWikpvmedXQJDSbxNqy7Xr/j2Y8/KfijM0iJyKkBTmWuvCA1yeH1yDM7NJhBW/2aXxeucLj6i80/LAJ/Q== dependencies: - "@babel/helper-module-transforms" "^7.20.11" - "@babel/helper-plugin-utils" "^7.20.2" - "@babel/helper-simple-access" "^7.20.2" + "@babel/helper-module-transforms" "^7.18.6" + "@babel/helper-plugin-utils" "^7.18.6" + "@babel/helper-simple-access" "^7.18.6" + babel-plugin-dynamic-import-node "^2.3.3" "@babel/plugin-transform-modules-systemjs@^7.19.6": version "7.20.11"