Next12 now supports ESM (#29295)
* Next12 now supports ESM * No more michael jackson script extensions * Fix test running * Update jest-puppeteer.config.cjs * Update package.json
This commit is contained in:
1
.github/package.json
vendored
1
.github/package.json
vendored
@@ -1 +0,0 @@
|
|||||||
{"type":"module"}
|
|
||||||
@@ -62,7 +62,7 @@ jobs:
|
|||||||
# Don't care about CDN caching image URLs
|
# Don't care about CDN caching image URLs
|
||||||
DISABLE_REWRITE_ASSET_URLS: true
|
DISABLE_REWRITE_ASSET_URLS: true
|
||||||
run: |
|
run: |
|
||||||
node server.mjs > /tmp/stdout.log 2> /tmp/stderr.log &
|
node server.js > /tmp/stdout.log 2> /tmp/stderr.log &
|
||||||
sleep 6
|
sleep 6
|
||||||
curl --retry-connrefused --retry 5 -I http://localhost:4000/
|
curl --retry-connrefused --retry 5 -I http://localhost:4000/
|
||||||
|
|
||||||
|
|||||||
@@ -64,7 +64,7 @@ jobs:
|
|||||||
DISABLE_RENDERING_CACHE: true
|
DISABLE_RENDERING_CACHE: true
|
||||||
run: |
|
run: |
|
||||||
|
|
||||||
node server.mjs &
|
node server.js &
|
||||||
sleep 5
|
sleep 5
|
||||||
curl --retry-connrefused --retry 3 -I http://localhost:4000/
|
curl --retry-connrefused --retry 3 -I http://localhost:4000/
|
||||||
|
|
||||||
|
|||||||
2
.github/workflows/code-lint.yml
vendored
2
.github/workflows/code-lint.yml
vendored
@@ -15,7 +15,7 @@ on:
|
|||||||
- '**.yaml'
|
- '**.yaml'
|
||||||
- '**.yml'
|
- '**.yml'
|
||||||
- '**.scss'
|
- '**.scss'
|
||||||
- .eslintrc.js
|
- .eslintrc.cjs
|
||||||
# In case something like eslint or tsc or prettier upgrades
|
# In case something like eslint or tsc or prettier upgrades
|
||||||
- 'package-lock.json'
|
- 'package-lock.json'
|
||||||
# Ultimately, for debugging this workflow itself
|
# Ultimately, for debugging this workflow itself
|
||||||
|
|||||||
@@ -10,7 +10,7 @@ on:
|
|||||||
- gh-readonly-queue/main/**
|
- gh-readonly-queue/main/**
|
||||||
pull_request:
|
pull_request:
|
||||||
paths:
|
paths:
|
||||||
- script/search/index-elasticsearch.mjs
|
- script/search/index-elasticsearch.js
|
||||||
- 'package*.json'
|
- 'package*.json'
|
||||||
- .github/workflows/dry-run-elasticsearch-indexing.yml
|
- .github/workflows/dry-run-elasticsearch-indexing.yml
|
||||||
|
|
||||||
@@ -63,7 +63,7 @@ jobs:
|
|||||||
env:
|
env:
|
||||||
ELASTICSEARCH_URL: 'http://localhost:9200'
|
ELASTICSEARCH_URL: 'http://localhost:9200'
|
||||||
run: |
|
run: |
|
||||||
./script/search/index-elasticsearch.mjs --verbose \
|
./script/search/index-elasticsearch.js --verbose \
|
||||||
-l en -l ja \
|
-l en -l ja \
|
||||||
-V dotcom -V ghes-3.5
|
-V dotcom -V ghes-3.5
|
||||||
|
|
||||||
|
|||||||
4
.github/workflows/link-check-all.yml
vendored
4
.github/workflows/link-check-all.yml
vendored
@@ -53,7 +53,7 @@ jobs:
|
|||||||
# Don't care about CDN caching image URLs
|
# Don't care about CDN caching image URLs
|
||||||
DISABLE_REWRITE_ASSET_URLS: true
|
DISABLE_REWRITE_ASSET_URLS: true
|
||||||
run: |
|
run: |
|
||||||
./script/rendered-content-link-checker.mjs \
|
./script/rendered-content-link-checker.js \
|
||||||
--language en \
|
--language en \
|
||||||
--max 100 \
|
--max 100 \
|
||||||
--check-anchors \
|
--check-anchors \
|
||||||
@@ -66,7 +66,7 @@ jobs:
|
|||||||
# Don't care about CDN caching image URLs
|
# Don't care about CDN caching image URLs
|
||||||
DISABLE_REWRITE_ASSET_URLS: true
|
DISABLE_REWRITE_ASSET_URLS: true
|
||||||
run: |
|
run: |
|
||||||
./script/rendered-content-link-checker.mjs \
|
./script/rendered-content-link-checker.js \
|
||||||
--language en \
|
--language en \
|
||||||
--exit \
|
--exit \
|
||||||
--verbose \
|
--verbose \
|
||||||
|
|||||||
4
.github/workflows/orphaned-assets-check.yml
vendored
4
.github/workflows/orphaned-assets-check.yml
vendored
@@ -40,7 +40,7 @@ jobs:
|
|||||||
run: |
|
run: |
|
||||||
set -e
|
set -e
|
||||||
|
|
||||||
./script/find-orphaned-assets.mjs | xargs git rm
|
./script/find-orphaned-assets.js | xargs git rm
|
||||||
|
|
||||||
# If nothing to commit, exit now. It's fine. No orphans.
|
# If nothing to commit, exit now. It's fine. No orphans.
|
||||||
git status | grep 'nothing to commit' && exit 0
|
git status | grep 'nothing to commit' && exit 0
|
||||||
@@ -58,6 +58,6 @@ jobs:
|
|||||||
|
|
||||||
gh pr create \
|
gh pr create \
|
||||||
--title "Delete orphaned assets ($date)" \
|
--title "Delete orphaned assets ($date)" \
|
||||||
--body "Found with the find-orphaned-assets.mjs script" \
|
--body "Found with the find-orphaned-assets.js script" \
|
||||||
--repo github/docs-internal \
|
--repo github/docs-internal \
|
||||||
--label docs-content-fr
|
--label docs-content-fr
|
||||||
|
|||||||
@@ -109,7 +109,7 @@ jobs:
|
|||||||
|
|
||||||
- name: Index into Elasticsearch
|
- name: Index into Elasticsearch
|
||||||
run: |
|
run: |
|
||||||
./script/search/index-elasticsearch.mjs \
|
./script/search/index-elasticsearch.js \
|
||||||
--language ${{ matrix.language }} \
|
--language ${{ matrix.language }} \
|
||||||
--source-directory /tmp/records
|
--source-directory /tmp/records
|
||||||
|
|
||||||
|
|||||||
@@ -74,7 +74,7 @@ ENV NODE_ENV production
|
|||||||
# Whether to hide iframes, add warnings to external links
|
# Whether to hide iframes, add warnings to external links
|
||||||
ENV AIRGAP false
|
ENV AIRGAP false
|
||||||
|
|
||||||
# Preferred port for server.mjs
|
# Preferred port for server.js
|
||||||
ENV PORT 4000
|
ENV PORT 4000
|
||||||
|
|
||||||
ENV ENABLED_LANGUAGES "en"
|
ENV ENABLED_LANGUAGES "en"
|
||||||
@@ -94,12 +94,12 @@ COPY --chown=node:node middleware ./middleware
|
|||||||
COPY --chown=node:node feature-flags.json ./
|
COPY --chown=node:node feature-flags.json ./
|
||||||
COPY --chown=node:node data ./data
|
COPY --chown=node:node data ./data
|
||||||
COPY --chown=node:node next.config.js ./
|
COPY --chown=node:node next.config.js ./
|
||||||
COPY --chown=node:node server.mjs ./server.mjs
|
COPY --chown=node:node server.js ./server.js
|
||||||
COPY --chown=node:node start-server.mjs ./start-server.mjs
|
COPY --chown=node:node start-server.js ./start-server.js
|
||||||
|
|
||||||
EXPOSE $PORT
|
EXPOSE $PORT
|
||||||
|
|
||||||
CMD ["node", "server.mjs"]
|
CMD ["node", "server.js"]
|
||||||
|
|
||||||
# --------------------------------------------------------------------------------
|
# --------------------------------------------------------------------------------
|
||||||
# PRODUCTION IMAGE - includes all translations
|
# PRODUCTION IMAGE - includes all translations
|
||||||
|
|||||||
@@ -1 +0,0 @@
|
|||||||
{"type":"module"}
|
|
||||||
@@ -13,7 +13,7 @@ if (testTranslation) {
|
|||||||
reporters.push('jest-github-actions-reporter')
|
reporters.push('jest-github-actions-reporter')
|
||||||
}
|
}
|
||||||
|
|
||||||
module.exports = {
|
export default {
|
||||||
coverageThreshold: {
|
coverageThreshold: {
|
||||||
global: {
|
global: {
|
||||||
branches: 95,
|
branches: 95,
|
||||||
@@ -41,6 +41,6 @@ module.exports = {
|
|||||||
],
|
],
|
||||||
testMatch: ['**/tests/**/*.js'],
|
testMatch: ['**/tests/**/*.js'],
|
||||||
testLocationInResults: isActions,
|
testLocationInResults: isActions,
|
||||||
globalSetup: './script/start-server-for-jest.mjs',
|
globalSetup: './script/start-server-for-jest.js',
|
||||||
globalTeardown: './script/kill-server-for-jest.mjs',
|
globalTeardown: './script/kill-server-for-jest.js',
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1 +0,0 @@
|
|||||||
{"type":"module"}
|
|
||||||
@@ -1 +0,0 @@
|
|||||||
{"type":"module"}
|
|
||||||
@@ -1,14 +1,11 @@
|
|||||||
// import { productIds } from './lib/all-products.js'
|
import fs from 'fs'
|
||||||
// import languages from './lib/languages.js'
|
import frontmatter from 'gray-matter'
|
||||||
|
import path from 'path'
|
||||||
const fs = require('fs')
|
|
||||||
const frontmatter = require('gray-matter')
|
|
||||||
const path = require('path')
|
|
||||||
const homepage = path.posix.join(process.cwd(), 'content/index.md')
|
const homepage = path.posix.join(process.cwd(), 'content/index.md')
|
||||||
const { data } = frontmatter(fs.readFileSync(homepage, 'utf8'))
|
const { data } = frontmatter(fs.readFileSync(homepage, 'utf8'))
|
||||||
const productIds = data.children
|
const productIds = data.children
|
||||||
|
|
||||||
module.exports = {
|
export default {
|
||||||
// speed up production `next build` by ignoring typechecking during that step of build.
|
// speed up production `next build` by ignoring typechecking during that step of build.
|
||||||
// type-checking still occurs in the Dockerfile build
|
// type-checking still occurs in the Dockerfile build
|
||||||
typescript: {
|
typescript: {
|
||||||
|
|||||||
17
package.json
17
package.json
@@ -169,7 +169,7 @@
|
|||||||
"engines": {
|
"engines": {
|
||||||
"node": ">=16.x"
|
"node": ">=16.x"
|
||||||
},
|
},
|
||||||
"exports": "./server.mjs",
|
"exports": "./server.js",
|
||||||
"license": "(MIT AND CC-BY-4.0)",
|
"license": "(MIT AND CC-BY-4.0)",
|
||||||
"name": "docs.github.com",
|
"name": "docs.github.com",
|
||||||
"optionalDependencies": {
|
"optionalDependencies": {
|
||||||
@@ -183,9 +183,9 @@
|
|||||||
"private": true,
|
"private": true,
|
||||||
"repository": "https://github.com/github/docs",
|
"repository": "https://github.com/github/docs",
|
||||||
"scripts": {
|
"scripts": {
|
||||||
"browser-test": "cross-env BROWSER=1 NODE_OPTIONS=--experimental-vm-modules jest tests/browser/browser.js",
|
"browser-test": "cross-env BROWSER=1 NODE_OPTIONS=--experimental-vm-modules JEST_PUPPETEER_CONFIG=jest-puppeteer.config.cjs jest tests/browser/browser.js",
|
||||||
"build": "next build",
|
"build": "next build",
|
||||||
"debug": "cross-env NODE_ENV=development ENABLED_LANGUAGES='en,ja' nodemon --inspect server.mjs",
|
"debug": "cross-env NODE_ENV=development ENABLED_LANGUAGES='en,ja' nodemon --inspect server.js",
|
||||||
"dev": "npm start",
|
"dev": "npm start",
|
||||||
"lint": "eslint '**/*.{js,mjs,ts,tsx}'",
|
"lint": "eslint '**/*.{js,mjs,ts,tsx}'",
|
||||||
"lint-translation": "cross-env NODE_OPTIONS=--experimental-vm-modules TEST_TRANSLATION=true jest tests/linting/lint-files.js",
|
"lint-translation": "cross-env NODE_OPTIONS=--experimental-vm-modules TEST_TRANSLATION=true jest tests/linting/lint-files.js",
|
||||||
@@ -195,14 +195,14 @@
|
|||||||
"prevent-pushes-to-main": "node script/prevent-pushes-to-main.js",
|
"prevent-pushes-to-main": "node script/prevent-pushes-to-main.js",
|
||||||
"rest-dev": "script/rest/update-files.js && npm run dev",
|
"rest-dev": "script/rest/update-files.js && npm run dev",
|
||||||
"show-action-deps": "echo 'Action Dependencies:' && rg '^[\\s|-]*(uses:.*)$' .github -I -N --no-heading -r '$1$2' | sort | uniq | cut -c 7-",
|
"show-action-deps": "echo 'Action Dependencies:' && rg '^[\\s|-]*(uses:.*)$' .github -I -N --no-heading -r '$1$2' | sort | uniq | cut -c 7-",
|
||||||
"start": "cross-env NODE_ENV=development ENABLED_LANGUAGES='en,ja' nodemon server.mjs",
|
"start": "cross-env NODE_ENV=development ENABLED_LANGUAGES='en,ja' nodemon server.js",
|
||||||
"start-all-languages": "cross-env NODE_ENV=development nodemon server.mjs",
|
"start-all-languages": "cross-env NODE_ENV=development nodemon server.js",
|
||||||
"sync-search": "cross-env NODE_OPTIONS='--max_old_space_size=8192' start-server-and-test sync-search-server 4002 sync-search-indices",
|
"sync-search": "cross-env NODE_OPTIONS='--max_old_space_size=8192' start-server-and-test sync-search-server 4002 sync-search-indices",
|
||||||
"sync-search-ghes-release": "cross-env GHES_RELEASE=1 start-server-and-test sync-search-server 4002 sync-search-indices",
|
"sync-search-ghes-release": "cross-env GHES_RELEASE=1 start-server-and-test sync-search-server 4002 sync-search-indices",
|
||||||
"sync-search-indices": "script/search/sync-search-indices.js",
|
"sync-search-indices": "script/search/sync-search-indices.js",
|
||||||
"sync-search-server": "cross-env NODE_ENV=production PORT=4002 CHANGELOG_DISABLED=true DISABLE_RENDERING_CACHE=true DISABLE_OVERLOAD_PROTECTION=true node server.mjs",
|
"sync-search-server": "cross-env NODE_ENV=production PORT=4002 CHANGELOG_DISABLED=true DISABLE_RENDERING_CACHE=true DISABLE_OVERLOAD_PROTECTION=true node server.js",
|
||||||
"translation-check": "start-server-and-test translation-check-server 4002 translation-check-test",
|
"translation-check": "start-server-and-test translation-check-server 4002 translation-check-test",
|
||||||
"translation-check-server": "cross-env NODE_ENV=test PORT=4002 node server.mjs",
|
"translation-check-server": "cross-env NODE_ENV=test PORT=4002 node server.js",
|
||||||
"translation-check-test": "script/i18n/test-html-pages.js",
|
"translation-check-test": "script/i18n/test-html-pages.js",
|
||||||
"test": "cross-env NODE_OPTIONS='--max_old_space_size=4096 --experimental-vm-modules' jest --logHeapUsage",
|
"test": "cross-env NODE_OPTIONS='--max_old_space_size=4096 --experimental-vm-modules' jest --logHeapUsage",
|
||||||
"test-watch": "cross-env NODE_OPTIONS=--experimental-vm-modules jest --watch --notify --notifyMode=change --coverage",
|
"test-watch": "cross-env NODE_OPTIONS=--experimental-vm-modules jest --watch --notify --notifyMode=change --coverage",
|
||||||
@@ -211,5 +211,6 @@
|
|||||||
"lint-staged": {
|
"lint-staged": {
|
||||||
"*.{js,mjs,ts,tsx}": "eslint --cache --fix",
|
"*.{js,mjs,ts,tsx}": "eslint --cache --fix",
|
||||||
"*.{js,mjs,scss,ts,tsx,yml,yaml}": "prettier --write"
|
"*.{js,mjs,scss,ts,tsx,yml,yaml}": "prettier --write"
|
||||||
}
|
},
|
||||||
|
"type": "module"
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -2,7 +2,7 @@
|
|||||||
|
|
||||||
import teardownJestPuppeteer from 'jest-environment-puppeteer/teardown.js'
|
import teardownJestPuppeteer from 'jest-environment-puppeteer/teardown.js'
|
||||||
|
|
||||||
import { START_JEST_SERVER, isServerHealthy, killServer } from './server-for-jest.mjs'
|
import { START_JEST_SERVER, isServerHealthy, killServer } from './server-for-jest.js'
|
||||||
|
|
||||||
export default async () => {
|
export default async () => {
|
||||||
if (START_JEST_SERVER) {
|
if (START_JEST_SERVER) {
|
||||||
@@ -1 +0,0 @@
|
|||||||
{"type":"module"}
|
|
||||||
@@ -2,9 +2,9 @@
|
|||||||
|
|
||||||
import setupJestPuppeteer from 'jest-environment-puppeteer/setup.js'
|
import setupJestPuppeteer from 'jest-environment-puppeteer/setup.js'
|
||||||
|
|
||||||
import { main } from '../start-server.mjs'
|
import { main } from '../start-server.js'
|
||||||
|
|
||||||
import { PORT, START_JEST_SERVER, isServerHealthy, isPortRunning } from './server-for-jest.mjs'
|
import { PORT, START_JEST_SERVER, isServerHealthy, isPortRunning } from './server-for-jest.js'
|
||||||
|
|
||||||
export default async () => {
|
export default async () => {
|
||||||
if (START_JEST_SERVER) {
|
if (START_JEST_SERVER) {
|
||||||
@@ -1,3 +0,0 @@
|
|||||||
import { main } from './start-server.mjs'
|
|
||||||
|
|
||||||
main()
|
|
||||||
@@ -89,7 +89,7 @@ since the server won't need to start and stop every time you run tests.
|
|||||||
In one terminal type:
|
In one terminal type:
|
||||||
|
|
||||||
```sh
|
```sh
|
||||||
NODE_ENV=test PORT=4000 node server.mjs
|
NODE_ENV=test PORT=4000 node server.js
|
||||||
```
|
```
|
||||||
|
|
||||||
and then, in another terminal type:
|
and then, in another terminal type:
|
||||||
|
|||||||
@@ -1 +0,0 @@
|
|||||||
{"type":"module"}
|
|
||||||
@@ -1029,7 +1029,7 @@ describe('static routes', () => {
|
|||||||
it('does not serve repo contents that live outside the /assets directory', async () => {
|
it('does not serve repo contents that live outside the /assets directory', async () => {
|
||||||
expect((await get('/package.json', { followRedirects: true })).statusCode).toBe(404)
|
expect((await get('/package.json', { followRedirects: true })).statusCode).toBe(404)
|
||||||
expect((await get('/README.md', { followRedirects: true })).statusCode).toBe(404)
|
expect((await get('/README.md', { followRedirects: true })).statusCode).toBe(404)
|
||||||
expect((await get('/server.mjs', { followRedirects: true })).statusCode).toBe(404)
|
expect((await get('/server.js', { followRedirects: true })).statusCode).toBe(404)
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user