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

Remove experimental tag from Script component #25435

Merged
merged 11 commits into from
Jun 3, 2021
3 changes: 0 additions & 3 deletions packages/next/build/webpack-config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1086,9 +1086,6 @@ export default async function getBaseWebpackConfig(
'process.env.__NEXT_OPTIMIZE_CSS': JSON.stringify(
config.experimental.optimizeCss && !dev
),
'process.env.__NEXT_SCRIPT_LOADER': JSON.stringify(
!!config.experimental.scriptLoader
),
'process.env.__NEXT_SCROLL_RESTORATION': JSON.stringify(
config.experimental.scrollRestoration
),
Expand Down
4 changes: 2 additions & 2 deletions packages/next/client/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -141,8 +141,8 @@ if (process.env.__NEXT_I18N_SUPPORT) {
}
}

if (process.env.__NEXT_SCRIPT_LOADER && data.scriptLoader) {
const { initScriptLoader } = require('./experimental-script')
if (data.scriptLoader) {
const { initScriptLoader } = require('./script')
initScriptLoader(data.scriptLoader)
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -136,10 +136,6 @@ function Script(props: Props): JSX.Element | null {
}
}, [props, strategy])

if (!process.env.__NEXT_SCRIPT_LOADER) {
return null
}

if (strategy === 'beforeInteractive') {
if (updateScripts) {
scripts.beforeInteractive = (scripts.beforeInteractive || []).concat([
Expand Down
2 changes: 0 additions & 2 deletions packages/next/experimental-script.d.ts

This file was deleted.

1 change: 0 additions & 1 deletion packages/next/experimental-script.js

This file was deleted.

2 changes: 0 additions & 2 deletions packages/next/next-server/server/config-shared.ts
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,6 @@ export type NextConfig = { [key: string]: any } & {
optimizeImages?: boolean
optimizeCss?: boolean
scrollRestoration?: boolean
scriptLoader?: boolean
stats?: boolean
externalDir?: boolean
conformance?: boolean
Expand Down Expand Up @@ -110,7 +109,6 @@ export const defaultConfig: NextConfig = {
optimizeImages: false,
optimizeCss: false,
scrollRestoration: false,
scriptLoader: false,
stats: false,
externalDir: false,
eslint: false,
Expand Down
4 changes: 2 additions & 2 deletions packages/next/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -28,8 +28,8 @@
"dynamic.d.ts",
"error.js",
"error.d.ts",
"experimental-script.js",
"experimental-script.d.ts",
"script.js",
"script.d.ts",
"head.js",
"head.d.ts",
"image.js",
Expand Down
8 changes: 2 additions & 6 deletions packages/next/pages/_document.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,7 @@ import {
} from '../next-server/server/get-page-files'
import { cleanAmpPath } from '../next-server/server/utils'
import { htmlEscapeJsonString } from '../server/htmlescape'
import Script, {
Props as ScriptLoaderProps,
} from '../client/experimental-script'
import Script, { Props as ScriptLoaderProps } from '../client/script'

export { DocumentContext, DocumentInitialProps, DocumentProps }

Expand Down Expand Up @@ -536,9 +534,7 @@ export class Head extends Component<
children = this.makeStylesheetInert(children)
}

if (process.env.__NEXT_SCRIPT_LOADER) {
children = this.handleDocumentScriptLoaderItems(children)
}
children = this.handleDocumentScriptLoaderItems(children)

let hasAmphtmlRel = false
let hasCanonicalRel = false
Expand Down
2 changes: 2 additions & 0 deletions packages/next/script.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
export * from './dist/client/script'
export { default } from './dist/client/script'
1 change: 1 addition & 0 deletions packages/next/script.js
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
module.exports = require('./dist/client/script')
8 changes: 4 additions & 4 deletions test/integration/build-output/test/index.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -123,16 +123,16 @@ describe('Build Output', () => {
)
expect(indexSize.endsWith('B')).toBe(true)

expect(parseFloat(indexFirstLoad)).toBeCloseTo(gz ? 63.3 : 194, 1)
expect(parseFloat(indexFirstLoad)).toBeCloseTo(gz ? 64 : 196, 1)
expect(indexFirstLoad.endsWith('kB')).toBe(true)

expect(parseFloat(err404Size)).toBeCloseTo(gz ? 3.06 : 8.15, 1)
expect(err404Size.endsWith('kB')).toBe(true)

expect(parseFloat(err404FirstLoad)).toBeCloseTo(gz ? 66.1 : 202, 1)
expect(parseFloat(err404FirstLoad)).toBeCloseTo(gz ? 66.8 : 204, 1)
expect(err404FirstLoad.endsWith('kB')).toBe(true)

expect(parseFloat(sharedByAll)).toBeCloseTo(gz ? 63 : 194, 1)
expect(parseFloat(sharedByAll)).toBeCloseTo(gz ? 63.7 : 196, 1)
expect(sharedByAll.endsWith('kB')).toBe(true)

const appSizeValue = _appSize.endsWith('kB')
Expand All @@ -149,7 +149,7 @@ describe('Build Output', () => {
true
)

expect(parseFloat(mainSize)).toBeCloseTo(gz ? 19.4 : 60.6, 1)
expect(parseFloat(mainSize)).toBeCloseTo(gz ? 20.1 : 62.8, 1)
expect(mainSize.endsWith('kB')).toBe(true)

expect(parseFloat(frameworkSize)).toBeCloseTo(gz ? 42.0 : 130, 1)
Expand Down
4 changes: 1 addition & 3 deletions test/integration/script-loader/next.config.js
Original file line number Diff line number Diff line change
@@ -1,3 +1 @@
module.exports = {
experimental: { scriptLoader: true },
}
module.exports = {}
2 changes: 1 addition & 1 deletion test/integration/script-loader/pages/_document.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import * as React from 'react'
/// @ts-ignore
import Document, { Main, NextScript, Head } from 'next/document'
import Script from 'next/experimental-script'
import Script from 'next/script'

export default class MyDocument extends Document {
constructor(props) {
Expand Down
2 changes: 1 addition & 1 deletion test/integration/script-loader/pages/index.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import Script from 'next/experimental-script'
import Script from 'next/script'

const Page = () => {
return (
Expand Down
2 changes: 1 addition & 1 deletion test/integration/script-loader/pages/page1.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import Script from 'next/experimental-script'
import Script from 'next/script'

const Page = () => {
return (
Expand Down
2 changes: 1 addition & 1 deletion test/integration/script-loader/pages/page3.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import Script from 'next/experimental-script'
import Script from 'next/script'

const Page = () => {
return (
Expand Down
2 changes: 1 addition & 1 deletion test/integration/script-loader/pages/page4.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import Script from 'next/experimental-script'
import Script from 'next/script'

const url =
'https://cdnjs.cloudflare.com/ajax/libs/lodash.js/4.17.20/lodash.min.js'
Expand Down
2 changes: 1 addition & 1 deletion test/integration/size-limit/test/index.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,6 @@ describe('Production response size', () => {
const delta = responseSizesBytes / 1024

// Expected difference: < 0.5
expect(delta).toBeCloseTo(286.7, 0)
expect(delta).toBeCloseTo(289.3, 0)
})
})