diff --git a/packages/gatsby-link/index.d.ts b/packages/gatsby-link/index.d.ts index b202dc4d6efa0..dec7c2cdf2a8d 100644 --- a/packages/gatsby-link/index.d.ts +++ b/packages/gatsby-link/index.d.ts @@ -24,7 +24,7 @@ export interface GatsbyLinkProps extends LinkProps { * This component is intended _only_ for links to pages handled by Gatsby. For links to pages on other * domains or pages on the same domain not handled by the current Gatsby site, use the normal `` element. */ -export default class GatsbyLink extends React.Component< +export class GatsbyLink extends React.Component< GatsbyLinkProps, any > {} diff --git a/packages/gatsby-link/package.json b/packages/gatsby-link/package.json index 397821f474066..f160eeb370d48 100644 --- a/packages/gatsby-link/package.json +++ b/packages/gatsby-link/package.json @@ -15,13 +15,9 @@ ], "sideEffects": false, "scripts": { - "build": "npm-run-all --npm-path npm -s build:cjs build:esm", + "build": "microbundle -i src/index.js -f cjs,modern --jsx React.createElement --generateTypes false", "postbuild": "prepend-directive --files=dist/index.js,dist/index.modern.mjs --directive=\"use client\"", - "build:cjs": "microbundle -f cjs --jsx React.createElement --generateTypes false -i src/index-cjs.js -o dist/index.js", - "build:esm": "microbundle -f modern --jsx React.createElement --generateTypes false -o dist/index.mjs", - "watch": "npm-run-all --npm-path npm -p watch:cjs watch:esm", - "watch:cjs": "npm run build:cjs watch --no-compress", - "watch:esm": "npm run build:esm watch --no-compress", + "watch": "npm run build watch --no-compress", "prepare": "cross-env NODE_ENV=production npm run clean && npm run build", "clean": "del-cli dist/*" }, @@ -35,7 +31,6 @@ "cross-env": "^7.0.3", "del-cli": "^5.0.0", "microbundle": "^0.15.1", - "npm-run-all": "^4.1.5", "prepend-directive": "^1.0.3" }, "peerDependencies": { diff --git a/packages/gatsby-link/src/__tests__/index.js b/packages/gatsby-link/src/__tests__/index.js index 9bbb5d7355bf0..3daa54d65c0b0 100644 --- a/packages/gatsby-link/src/__tests__/index.js +++ b/packages/gatsby-link/src/__tests__/index.js @@ -9,7 +9,7 @@ import { createHistory, LocationProvider, } from "@reach/router" -import Link, { navigate, withPrefix, withAssetPrefix } from "../" +import { Link, navigate, withPrefix, withAssetPrefix } from "../" beforeEach(() => { global.__BASE_PATH__ = `` diff --git a/packages/gatsby-link/src/index-cjs.js b/packages/gatsby-link/src/index-cjs.js deleted file mode 100644 index 30a04d45ec5dc..0000000000000 --- a/packages/gatsby-link/src/index-cjs.js +++ /dev/null @@ -1,10 +0,0 @@ -import * as Link from "./index.js" - -module.exports = Link.default - -Object.getOwnPropertyNames(Link).forEach(key => { - Object.defineProperty(module.exports, key, { - value: Link[key], - enumerable: true, - }) -}) diff --git a/packages/gatsby-link/src/index.js b/packages/gatsby-link/src/index.js index 67cc83d6eee3c..1024670e6d82e 100644 --- a/packages/gatsby-link/src/index.js +++ b/packages/gatsby-link/src/index.js @@ -1,6 +1,6 @@ import PropTypes from "prop-types" import React from "react" -import { Link, Location } from "@gatsbyjs/reach-router" +import { Link as ReachRouterLink, Location } from "@gatsbyjs/reach-router" import { parsePath } from "./parse-path" import { isLocalLink } from "./is-local-link" import { rewriteLinkPath } from "./rewrite-link-path" @@ -162,7 +162,7 @@ class GatsbyLink extends React.Component { } return ( - ( +export const Link = React.forwardRef((props, ref) => ( )) diff --git a/packages/gatsby/cache-dir/gatsby-browser-entry.js b/packages/gatsby/cache-dir/gatsby-browser-entry.js index 65218f27844e2..481717038c5c1 100644 --- a/packages/gatsby/cache-dir/gatsby-browser-entry.js +++ b/packages/gatsby/cache-dir/gatsby-browser-entry.js @@ -14,7 +14,7 @@ function graphql() { export { default as PageRenderer } from "./public-page-renderer" export { useScrollRestoration } from "gatsby-react-router-scroll" export { - default as Link, + Link, withPrefix, withAssetPrefix, navigate, diff --git a/packages/gatsby/index.d.ts b/packages/gatsby/index.d.ts index 48dc6ec78cf57..8ec52735f14b1 100644 --- a/packages/gatsby/index.d.ts +++ b/packages/gatsby/index.d.ts @@ -23,7 +23,7 @@ export type AvailableFeatures = | "content-file-path" export { - default as Link, + Link, GatsbyLinkProps, navigate, withPrefix, @@ -454,10 +454,7 @@ export interface GatsbyNode< * @example * exports.shouldOnCreateNode = ({node}, pluginOptions) => node.internal.type === 'Image' */ - shouldOnCreateNode?( - args: { node: TNode }, - options: PluginOptions - ): boolean + shouldOnCreateNode?(args: { node: TNode }, options: PluginOptions): boolean /** * Called when a new page is created. This extension API is useful