Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore(gatsby,gatsby-link): Export Link as named export #36888

Merged
merged 3 commits into from
Oct 27, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion packages/gatsby-link/index.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ export interface GatsbyLinkProps<TState> extends LinkProps<TState> {
* 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 `<a>` element.
*/
export default class GatsbyLink<TState> extends React.Component<
export class GatsbyLink<TState> extends React.Component<
GatsbyLinkProps<TState>,
any
> {}
Expand Down
9 changes: 2 additions & 7 deletions packages/gatsby-link/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -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/*"
},
Expand All @@ -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": {
Expand Down
2 changes: 1 addition & 1 deletion packages/gatsby-link/src/__tests__/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -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__ = ``
Expand Down
10 changes: 0 additions & 10 deletions packages/gatsby-link/src/index-cjs.js

This file was deleted.

6 changes: 3 additions & 3 deletions packages/gatsby-link/src/index.js
Original file line number Diff line number Diff line change
@@ -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"
Expand Down Expand Up @@ -162,7 +162,7 @@ class GatsbyLink extends React.Component {
}

return (
<Link
<ReachRouterLink
to={prefixedTo}
state={state}
getProps={getProps}
Expand Down Expand Up @@ -220,7 +220,7 @@ GatsbyLink.propTypes = {
state: PropTypes.object,
}

export default React.forwardRef((props, ref) => (
export const Link = React.forwardRef((props, ref) => (
<GatsbyLinkLocationWrapper innerRef={ref} {...props} />
))

Expand Down
2 changes: 1 addition & 1 deletion packages/gatsby/cache-dir/gatsby-browser-entry.js
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
7 changes: 2 additions & 5 deletions packages/gatsby/index.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ export type AvailableFeatures =
| "content-file-path"

export {
default as Link,
Link,
GatsbyLinkProps,
navigate,
withPrefix,
Expand Down Expand Up @@ -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
Expand Down