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

Don't bundle prop-types to then tree shake it #9944

Merged
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
6 changes: 3 additions & 3 deletions packages/next/client/link.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ declare const __NEXT_DATA__: any

import { resolve, parse, UrlObject } from 'url'
import React, { Component, Children } from 'react'
import PropTypes from 'prop-types'
import Router from './router'
import { rewriteUrlForNextExport } from '../next-server/lib/router/rewrite-url-for-export'
import {
Expand Down Expand Up @@ -108,7 +107,6 @@ const listenToIntersections = (el: any, cb: any) => {
}

class Link extends Component<LinkProps> {
static propTypes?: any
p: boolean

constructor(props: LinkProps) {
Expand Down Expand Up @@ -283,7 +281,9 @@ if (process.env.NODE_ENV === 'development') {
const warn = execOnce(console.error)

// This module gets removed by webpack.IgnorePlugin
const PropTypes = require('prop-types')
const exact = require('prop-types-exact')
// @ts-ignore the property is supported, when declaring it on the class it outputs an extra bit of code which is not needed.
Link.propTypes = exact({
href: PropTypes.oneOfType([PropTypes.string, PropTypes.object]).isRequired,
as: PropTypes.oneOfType([PropTypes.string, PropTypes.object]),
Expand All @@ -294,7 +294,7 @@ if (process.env.NODE_ENV === 'development') {
scroll: PropTypes.bool,
children: PropTypes.oneOfType([
PropTypes.element,
(props: any, propName) => {
(props: any, propName: string) => {
const value = props[propName]

if (typeof value === 'string') {
Expand Down