Skip to content

Commit 5a88dbb

Browse files
authoredOct 27, 2022
chore(gatsby,gatsby-link): Export Link as named export (#36888)
1 parent 4fadb28 commit 5a88dbb

File tree

7 files changed

+10
-28
lines changed

7 files changed

+10
-28
lines changed
 

‎packages/gatsby-link/index.d.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ export interface GatsbyLinkProps<TState> extends LinkProps<TState> {
2424
* This component is intended _only_ for links to pages handled by Gatsby. For links to pages on other
2525
* domains or pages on the same domain not handled by the current Gatsby site, use the normal `<a>` element.
2626
*/
27-
export default class GatsbyLink<TState> extends React.Component<
27+
export class GatsbyLink<TState> extends React.Component<
2828
GatsbyLinkProps<TState>,
2929
any
3030
> {}

‎packages/gatsby-link/package.json

+2-7
Original file line numberDiff line numberDiff line change
@@ -15,13 +15,9 @@
1515
],
1616
"sideEffects": false,
1717
"scripts": {
18-
"build": "npm-run-all --npm-path npm -s build:cjs build:esm",
18+
"build": "microbundle -i src/index.js -f cjs,modern --jsx React.createElement --generateTypes false",
1919
"postbuild": "prepend-directive --files=dist/index.js,dist/index.modern.mjs --directive=\"use client\"",
20-
"build:cjs": "microbundle -f cjs --jsx React.createElement --generateTypes false -i src/index-cjs.js -o dist/index.js",
21-
"build:esm": "microbundle -f modern --jsx React.createElement --generateTypes false -o dist/index.mjs",
22-
"watch": "npm-run-all --npm-path npm -p watch:cjs watch:esm",
23-
"watch:cjs": "npm run build:cjs watch --no-compress",
24-
"watch:esm": "npm run build:esm watch --no-compress",
20+
"watch": "npm run build watch --no-compress",
2521
"prepare": "cross-env NODE_ENV=production npm run clean && npm run build",
2622
"clean": "del-cli dist/*"
2723
},
@@ -35,7 +31,6 @@
3531
"cross-env": "^7.0.3",
3632
"del-cli": "^5.0.0",
3733
"microbundle": "^0.15.1",
38-
"npm-run-all": "^4.1.5",
3934
"prepend-directive": "^1.0.3"
4035
},
4136
"peerDependencies": {

‎packages/gatsby-link/src/__tests__/index.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ import {
99
createHistory,
1010
LocationProvider,
1111
} from "@reach/router"
12-
import Link, { navigate, withPrefix, withAssetPrefix } from "../"
12+
import { Link, navigate, withPrefix, withAssetPrefix } from "../"
1313

1414
beforeEach(() => {
1515
global.__BASE_PATH__ = ``

‎packages/gatsby-link/src/index-cjs.js

-10
This file was deleted.

‎packages/gatsby-link/src/index.js

+3-3
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import PropTypes from "prop-types"
22
import React from "react"
3-
import { Link, Location } from "@gatsbyjs/reach-router"
3+
import { Link as ReachRouterLink, Location } from "@gatsbyjs/reach-router"
44
import { parsePath } from "./parse-path"
55
import { isLocalLink } from "./is-local-link"
66
import { rewriteLinkPath } from "./rewrite-link-path"
@@ -162,7 +162,7 @@ class GatsbyLink extends React.Component {
162162
}
163163

164164
return (
165-
<Link
165+
<ReachRouterLink
166166
to={prefixedTo}
167167
state={state}
168168
getProps={getProps}
@@ -220,7 +220,7 @@ GatsbyLink.propTypes = {
220220
state: PropTypes.object,
221221
}
222222

223-
export default React.forwardRef((props, ref) => (
223+
export const Link = React.forwardRef((props, ref) => (
224224
<GatsbyLinkLocationWrapper innerRef={ref} {...props} />
225225
))
226226

‎packages/gatsby/cache-dir/gatsby-browser-entry.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ function graphql() {
1414
export { default as PageRenderer } from "./public-page-renderer"
1515
export { useScrollRestoration } from "gatsby-react-router-scroll"
1616
export {
17-
default as Link,
17+
Link,
1818
withPrefix,
1919
withAssetPrefix,
2020
navigate,

‎packages/gatsby/index.d.ts

+2-5
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ export type AvailableFeatures =
2323
| "content-file-path"
2424

2525
export {
26-
default as Link,
26+
Link,
2727
GatsbyLinkProps,
2828
navigate,
2929
withPrefix,
@@ -454,10 +454,7 @@ export interface GatsbyNode<
454454
* @example
455455
* exports.shouldOnCreateNode = ({node}, pluginOptions) => node.internal.type === 'Image'
456456
*/
457-
shouldOnCreateNode?(
458-
args: { node: TNode },
459-
options: PluginOptions
460-
): boolean
457+
shouldOnCreateNode?(args: { node: TNode }, options: PluginOptions): boolean
461458

462459
/**
463460
* Called when a new page is created. This extension API is useful

0 commit comments

Comments
 (0)
Please sign in to comment.