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

the way towards webpack 5 typings #29105

Merged
merged 35 commits into from
Sep 21, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
35 commits
Select commit Hold shift + click to select a range
b8e933b
name all dependencies with multiple version by their version
sokra Sep 15, 2021
e7bd7f2
Merge branch 'canary' into refactor/types
sokra Sep 16, 2021
46394a0
fix async modules test case which was never executed before
sokra Sep 16, 2021
7857e86
add missing require hooks which are used by test cases
sokra Sep 16, 2021
b5d3cab
fix require path for webpack 4
sokra Sep 16, 2021
f95ca32
remove left-over debugger
sokra Sep 16, 2021
ea0b3aa
fix react-refresh-utils types
sokra Sep 16, 2021
90e0baf
Merge branch 'canary' into refactor/types
sokra Sep 16, 2021
d2167c7
remove outdated comment
sokra Sep 16, 2021
2d426ff
fix amp usage
sokra Sep 16, 2021
f93a76a
migrate test case to nextStart
sokra Sep 16, 2021
b76ab2e
Merge branch 'canary' into refactor/types
sokra Sep 17, 2021
44994cc
improve test runner to avoid throwing when stopping
sokra Sep 17, 2021
69b12c2
skip test in webpack 4
sokra Sep 17, 2021
b7a8469
update ncced files
sokra Sep 17, 2021
be32d98
Merge branch 'canary' into refactor/types
sokra Sep 20, 2021
7e40d0d
improve check-precompiled script
sokra Sep 20, 2021
1c16ef9
fix test case
sokra Sep 20, 2021
c36a64e
fix precompiled files
sokra Sep 21, 2021
f68fd5f
Merge branch 'canary' into refactor/types
sokra Sep 21, 2021
1d75cd2
fix types for new code
sokra Sep 21, 2021
e64d057
try to get consistent pre-compiled files
sokra Sep 21, 2021
4b6fa65
automatically update pre compiled files
sokra Sep 21, 2021
f127628
remove workarounds
sokra Sep 21, 2021
7fae5a1
need to checkout before commit
sokra Sep 21, 2021
a765fb0
fix pre-committed commit action
sokra Sep 21, 2021
84669da
fix pre-committed commit action
sokra Sep 21, 2021
e79b96e
⚙ Update compiled files
sokra Sep 21, 2021
3384ddd
workaround yarn hoisting problem
sokra Sep 21, 2021
5fcc177
keep line endings
sokra Sep 21, 2021
b198d3a
restore dependency
sokra Sep 21, 2021
93303bd
install chromium
sokra Sep 21, 2021
f4683bb
Merge branch 'canary' into refactor/types
sokra Sep 21, 2021
8e4e059
Revert "install chromium"
sokra Sep 21, 2021
147f46d
Merge branch 'canary' into refactor/types
sokra Sep 21, 2021
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
2 changes: 2 additions & 0 deletions .gitattributes
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
packages/next/bundles/** -text
packages/next/compiled/** -text
75 changes: 60 additions & 15 deletions .github/workflows/build_test_deploy.yml
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,9 @@ jobs:
- uses: actions/cache@v2
id: cache-build
with:
path: ./*
path: |
./*
!./.git
key: ${{ github.sha }}

lint:
Expand All @@ -63,7 +65,9 @@ jobs:
- uses: actions/cache@v2
id: restore-build
with:
path: ./*
path: |
./*
!./.git
key: ${{ github.sha }}
- run: ./scripts/check-manifests.js
- run: yarn lint
Expand All @@ -75,29 +79,44 @@ jobs:
env:
NEXT_TELEMETRY_DISABLED: 1
steps:
- uses: actions/checkout@v2
if: ${{needs.build.outputs.docsChange != 'docs only change'}}

# https://github.com/actions/virtual-environments/issues/1187
- name: tune linux network
if: ${{needs.build.outputs.docsChange != 'docs only change'}}
run: sudo ethtool -K eth0 tx off rx off

- uses: actions/cache@v2
if: ${{needs.build.outputs.docsChange != 'docs only change'}}
id: restore-build
with:
path: ./*
path: |
./*
!./.git
key: ${{ github.sha }}

- uses: actions/download-artifact@v2
if: ${{needs.build.outputs.docsChange != 'docs only change'}}
with:
name: next-swc-binaries
path: packages/next/build/swc/dist

# Only check linux build for now, mac builds can sometimes be different even with the same code
- run: |
mv ./packages/next/build/swc/dist/next-swc.linux-x64-gnu.node \
./packages/next/native/next-swc.linux-x64-gnu.node
if: ${{needs.build.outputs.docsChange != 'docs only change'}}

- run: ./scripts/check-pre-compiled.sh
if: ${{needs.build.outputs.docsChange != 'docs only change'}}

- uses: EndBug/add-and-commit@v7
if: ${{ failure() }}
with:
add: 'packages/next/compiled packages/next/bundles --force'
message: '⚙ Update compiled files'

testUnit:
name: Test Unit
runs-on: ubuntu-latest
Expand All @@ -110,7 +129,9 @@ jobs:
if: ${{needs.build.outputs.docsChange != 'docs only change'}}
id: restore-build
with:
path: ./*
path: |
./*
!./.git
key: ${{ github.sha }}

- run: node run-tests.js --type unit
Expand All @@ -134,7 +155,9 @@ jobs:
if: ${{needs.build.outputs.docsChange != 'docs only change'}}
id: restore-build
with:
path: ./*
path: |
./*
!./.git
key: ${{ github.sha }}

- run: npm i -g playwright-chromium@1.14.1 && npx playwright install-deps
Expand Down Expand Up @@ -170,7 +193,9 @@ jobs:
if: ${{needs.build.outputs.docsChange != 'docs only change'}}
id: restore-build
with:
path: ./*
path: |
./*
!./.git
key: ${{ github.sha }}

- run: npm i -g playwright-chromium@1.14.1 && npx playwright install-deps
Expand Down Expand Up @@ -210,7 +235,9 @@ jobs:
if: ${{needs.build.outputs.docsChange != 'docs only change'}}
id: restore-build
with:
path: ./*
path: |
./*
!./.git
key: ${{ github.sha }}

- run: npm i -g playwright-chromium@1.14.1 && npx playwright install-deps
Expand All @@ -236,7 +263,9 @@ jobs:
if: ${{needs.build.outputs.docsChange != 'docs only change'}}
id: restore-build
with:
path: ./*
path: |
./*
!./.git
key: ${{ github.sha }}

# TODO: remove after we fix watchpack watching too much
Expand All @@ -260,7 +289,9 @@ jobs:
if: ${{needs.build.outputs.docsChange != 'docs only change'}}
id: restore-build
with:
path: ./*
path: |
./*
!./.git
key: ${{ github.sha }}

- run: bash ./scripts/test-pnp.sh
Expand All @@ -272,6 +303,8 @@ jobs:
needs:
[
lint,
check-examples,
test-native,
checkPrecompiled,
testIntegration,
testUnit,
Expand Down Expand Up @@ -300,7 +333,9 @@ jobs:
if: ${{needs.build.outputs.docsChange != 'docs only change'}}
id: restore-build
with:
path: ./*
path: |
./*
!./.git
key: ${{ github.sha }}

- run: npm i -g playwright-chromium@1.14.1 && npx playwright install-deps
Expand All @@ -321,7 +356,9 @@ jobs:
if: ${{needs.build.outputs.docsChange != 'docs only change'}}
id: restore-build
with:
path: ./*
path: |
./*
!./.git
key: ${{ github.sha }}
- run: npx playwright install-deps && npx playwright install firefox
if: ${{needs.build.outputs.docsChange != 'docs only change'}}
Expand All @@ -348,7 +385,9 @@ jobs:
if: ${{needs.build.outputs.docsChange != 'docs only change'}}
id: restore-build
with:
path: ./*
path: |
./*
!./.git
key: ${{ github.sha }}

# TODO: use macos runner so that we can use playwright to test against
Expand Down Expand Up @@ -380,7 +419,9 @@ jobs:
if: ${{needs.build.outputs.docsChange != 'docs only change'}}
id: restore-build
with:
path: ./*
path: |
./*
!./.git
key: ${{ github.sha }}

- run: '[[ -z "$BROWSERSTACK_ACCESS_KEY" ]] && echo "Skipping for PR" || npm i -g browserstack-local@1.4.0'
Expand All @@ -404,7 +445,9 @@ jobs:
- uses: actions/cache@v2
id: restore-build
with:
path: ./*
path: |
./*
!./.git
key: ${{ github.sha }}
- uses: actions/download-artifact@v2
with:
Expand All @@ -422,7 +465,9 @@ jobs:
- uses: actions/cache@v2
id: restore-build
with:
path: ./*
path: |
./*
!./.git
key: ${{ github.sha }}
- run: ./scripts/release-stats.sh
- uses: ./.github/actions/next-stats-action
Expand Down
21 changes: 20 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
{
"name": "nextjs-project",
"version": "0.0.0",
"private": true,
"workspaces": [
"packages/*"
Expand Down Expand Up @@ -61,14 +62,32 @@
"@typescript-eslint/eslint-plugin": "4.29.1",
"@typescript-eslint/parser": "4.29.1",
"@vercel/fetch": "6.1.1",
"@webassemblyjs/ast": "1.11.1",
"@webassemblyjs/floating-point-hex-parser": "1.11.1",
"@webassemblyjs/helper-api-error": "1.11.1",
"@webassemblyjs/helper-buffer": "1.11.1",
"@webassemblyjs/helper-code-frame": "npm:empty-npm-package@1.0.0",
"@webassemblyjs/helper-module-context": "npm:empty-npm-package@1.0.0",
"@webassemblyjs/helper-numbers": "1.11.1",
"@webassemblyjs/helper-wasm-bytecode": "1.11.1",
"@webassemblyjs/helper-wasm-section": "1.11.1",
"@webassemblyjs/ieee754": "1.11.1",
"@webassemblyjs/leb128": "1.11.1",
"@webassemblyjs/utf8": "1.11.1",
"@webassemblyjs/wasm-edit": "1.11.1",
"@webassemblyjs/wasm-gen": "1.11.1",
"@webassemblyjs/wasm-opt": "1.11.1",
"@webassemblyjs/wasm-parser": "1.11.1",
"@webassemblyjs/wast-parser": "npm:empty-npm-package@1.0.0",
"@webassemblyjs/wast-printer": "1.11.1",
"@zeit/next-css": "1.0.2-canary.2",
"@zeit/next-sass": "1.0.2-canary.2",
"@zeit/next-typescript": "1.1.2-canary.0",
"abort-controller": "3.0.0",
"alex": "9.1.0",
"amphtml-validator": "1.0.33",
"async-sema": "3.0.1",
"browserslist": "^4.14.7",
"browserslist": "4.16.6",
"cheerio": "0.22.0",
"clone": "2.1.2",
"cookie": "0.4.1",
Expand Down
21 changes: 5 additions & 16 deletions packages/next/build/entries.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ import { ClientPagesLoaderOptions } from './webpack/loaders/next-client-pages-lo
import { ServerlessLoaderQuery } from './webpack/loaders/next-serverless-loader'
import { LoadedEnvFiles } from '@next/env'
import { NextConfigComplete } from '../server/config-shared'
import type webpack5 from 'webpack5'

type PagesMapping = {
[page: string]: string
Expand Down Expand Up @@ -62,21 +63,9 @@ export function createPagesMapping(
return pages
}

export type WebpackEntrypoints = {
[bundle: string]:
| string
| string[]
| {
import: string | string[]
dependOn?: string | string[]
publicPath?: string
runtime?: string
}
}

type Entrypoints = {
client: WebpackEntrypoints
server: WebpackEntrypoints
client: webpack5.EntryObject
server: webpack5.EntryObject
}

export function createEntrypoints(
Expand All @@ -87,8 +76,8 @@ export function createEntrypoints(
config: NextConfigComplete,
loadedEnvFiles: LoadedEnvFiles
): Entrypoints {
const client: WebpackEntrypoints = {}
const server: WebpackEntrypoints = {}
const client: webpack5.EntryObject = {}
const server: webpack5.EntryObject = {}

const hasRuntimeConfig =
Object.keys(config.publicRuntimeConfig).length > 0 ||
Expand Down
27 changes: 15 additions & 12 deletions packages/next/build/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -840,22 +840,25 @@ export async function isPageStatic(
try {
require('../shared/lib/runtime-config').setConfig(runtimeEnvConfig)
setHttpAgentOptions(httpAgentOptions)
const components = await loadComponents(distDir, page, serverless)
const mod = components.ComponentMod
const Comp = mod.default || mod
const mod = await loadComponents(distDir, page, serverless)
const Comp = mod.Component

if (!Comp || !isValidElementType(Comp) || typeof Comp === 'string') {
throw new Error('INVALID_DEFAULT_EXPORT')
}

const hasGetInitialProps = !!(Comp as any).getInitialProps
const hasStaticProps = !!(await mod.getStaticProps)
const hasStaticPaths = !!(await mod.getStaticPaths)
const hasServerProps = !!(await mod.getServerSideProps)
const hasLegacyServerProps = !!(await mod.unstable_getServerProps)
const hasLegacyStaticProps = !!(await mod.unstable_getStaticProps)
const hasLegacyStaticPaths = !!(await mod.unstable_getStaticPaths)
const hasLegacyStaticParams = !!(await mod.unstable_getStaticParams)
const hasStaticProps = !!mod.getStaticProps
const hasStaticPaths = !!mod.getStaticPaths
const hasServerProps = !!mod.getServerSideProps
const hasLegacyServerProps = !!(await mod.ComponentMod
.unstable_getServerProps)
const hasLegacyStaticProps = !!(await mod.ComponentMod
.unstable_getStaticProps)
const hasLegacyStaticPaths = !!(await mod.ComponentMod
.unstable_getStaticPaths)
const hasLegacyStaticParams = !!(await mod.ComponentMod
.unstable_getStaticParams)

if (hasLegacyStaticParams) {
throw new Error(
Expand Down Expand Up @@ -921,14 +924,14 @@ export async function isPageStatic(
encodedPaths: encodedPrerenderRoutes,
} = await buildStaticPaths(
page,
mod.getStaticPaths,
mod.getStaticPaths!,
locales,
defaultLocale
))
}

const isNextImageImported = (global as any).__NEXT_IMAGE_IMPORTED
const config: PageConfig = mod.config || {}
const config: PageConfig = mod.pageConfig
return {
isStatic: !hasStaticProps && !hasGetInitialProps && !hasServerProps,
isHybridAmp: config.amp === 'hybrid',
Expand Down