Commit 5beb365d authored by JJ Kasper's avatar JJ Kasper Committed by Tim Neutkens

Add retrying to CircleCi and fixes for ncc'ed webpack (#7366)

* Add retrying to CircleCi and run prepublish separately to get better logs in Azure

* Apply workaround for Azure node 10 and ncc

* Update incorrect webpack imports

* Use ncced autodll-webpack-plugin

* Move autodll-webpack-plugin to devDependencies
parent 84f8addf
...@@ -46,7 +46,7 @@ commands: ...@@ -46,7 +46,7 @@ commands:
- run: - run:
name: Run All Tests name: Run All Tests
command: > command: >
yarn testall $(circleci tests glob "test/**/*.test.*" | circleci tests split --split-by=timings --timings-type=classname) yarn testall $(circleci tests glob "test/**/*.test.*" | circleci tests split --split-by=timings --timings-type=classname) || (yarn git-clean; yarn git-reset; yarn testall $(circleci tests glob "test/**/*.test.*" | circleci tests split --split-by=timings --timings-type=classname))
environment: environment:
JEST_JUNIT_OUTPUT: 'reports/junit/js-test-results.xml' JEST_JUNIT_OUTPUT: 'reports/junit/js-test-results.xml'
JEST_JUNIT_CLASSNAME: '{filepath}' JEST_JUNIT_CLASSNAME: '{filepath}'
......
import { loader } from 'webpack' import { loader } from 'next/dist/compiled/webpack'
const NoopLoader: loader.Loader = (source) => source const NoopLoader: loader.Loader = (source) => source
export default NoopLoader export default NoopLoader
import path from 'path' import path from 'path'
export function importAutoDllPlugin({ distDir }: { distDir: string }) { export function importAutoDllPlugin({ distDir }: { distDir: string }) {
const autodllPaths = path.join( const autodllPaths = require.resolve(
path.dirname(require.resolve('autodll-webpack-plugin')), 'next/dist/compiled/autodll-webpack-plugin/paths'
'paths.js'
) )
require(autodllPaths) require(autodllPaths)
...@@ -18,6 +17,6 @@ export function importAutoDllPlugin({ distDir }: { distDir: string }) { ...@@ -18,6 +17,6 @@ export function importAutoDllPlugin({ distDir }: { distDir: string }) {
}), }),
}) })
const AutoDllPlugin = require('autodll-webpack-plugin') const AutoDllPlugin = require('next/dist/compiled/autodll-webpack-plugin')
return AutoDllPlugin return AutoDllPlugin
} }
import ForkTsCheckerWebpackPlugin from 'fork-ts-checker-webpack-plugin' import ForkTsCheckerWebpackPlugin from 'fork-ts-checker-webpack-plugin'
import { NormalizedMessage } from 'fork-ts-checker-webpack-plugin/lib/NormalizedMessage' import { NormalizedMessage } from 'fork-ts-checker-webpack-plugin/lib/NormalizedMessage'
import webpack from 'webpack' import webpack from 'next/dist/compiled/webpack'
export function Apply(compiler: webpack.Compiler) { export function Apply(compiler: webpack.Compiler) {
const hooks = ForkTsCheckerWebpackPlugin.getCompilerHooks(compiler) const hooks = ForkTsCheckerWebpackPlugin.getCompilerHooks(compiler as any)
let additionalFiles: string[] = [] let additionalFiles: string[] = []
......
...@@ -68,7 +68,6 @@ ...@@ -68,7 +68,6 @@
"@babel/runtime-corejs2": "7.1.2", "@babel/runtime-corejs2": "7.1.2",
"amphtml-validator": "1.0.23", "amphtml-validator": "1.0.23",
"async-sema": "2.2.0", "async-sema": "2.2.0",
"autodll-webpack-plugin": "0.4.2",
"babel-core": "7.0.0-bridge.0", "babel-core": "7.0.0-bridge.0",
"babel-loader": "8.0.5", "babel-loader": "8.0.5",
"babel-plugin-react-require": "3.0.0", "babel-plugin-react-require": "3.0.0",
......
'use strict' 'use strict'
// this fixes Azure on node 10 with ncc
// without exits with: error Command failed with exit code 3221225477.
process.pkg = true
const ncc = require('@zeit/ncc') const ncc = require('@zeit/ncc')
const { existsSync, readFileSync } = require('fs') const { existsSync, readFileSync } = require('fs')
...@@ -22,6 +25,13 @@ module.exports = function (task) { ...@@ -22,6 +25,13 @@ module.exports = function (task) {
if (options && options.packageName) { if (options && options.packageName) {
writePackageManifest.call(this, options.packageName) writePackageManifest.call(this, options.packageName)
} }
// make sure to use our compiled version of webpack
code = code
.replace(/require\(('|")webpack('|")\)/g, 'require("next/dist/compiled/webpack")')
.replace(
/webpack\/lib\/node\/NodeOutputFileSystem/g,
'next/dist/compiled/webpack/lib/node/NodeOutputFileSystem'
)
file.data = Buffer.from(code, 'utf8') file.data = Buffer.from(code, 'utf8')
}) })
......
const notifier = require('node-notifier') const notifier = require('node-notifier')
const relative = require('path').relative const { relative } = require('path')
const babelClientOpts = { const babelClientOpts = {
presets: [ presets: [
...@@ -55,6 +55,18 @@ export async function ncc_webpack (task, opts) { ...@@ -55,6 +55,18 @@ export async function ncc_webpack (task, opts) {
notify('Compiled webpack') notify('Compiled webpack')
} }
// eslint-disable-next-line camelcase
export async function ncc_webpack_NodeOutputFileSystem (task, opts) {
await task
.source(opts.src || relative(__dirname, require.resolve('webpack/lib/node/NodeOutputFileSystem')))
.ncc({
externals: ['webpack']
})
.target('dist/compiled/webpack/lib/node/NodeOutputFileSystem')
notify('Compiled webpack NodeOutputFileSystem')
}
// eslint-disable-next-line camelcase // eslint-disable-next-line camelcase
export async function ncc_webpack_graph_helpers (task, opts) { export async function ncc_webpack_graph_helpers (task, opts) {
await task await task
...@@ -83,7 +95,7 @@ export async function ncc_autodll_webpack_plugin (task, opts) { ...@@ -83,7 +95,7 @@ export async function ncc_autodll_webpack_plugin (task, opts) {
await task await task
.source(opts.src || relative(__dirname, require.resolve('autodll-webpack-plugin'))) .source(opts.src || relative(__dirname, require.resolve('autodll-webpack-plugin')))
.ncc({ .ncc({
externals: ['chokidar', 'webpack'], externals: ['chokidar', 'webpack', './paths'],
packageName: 'autodll-webpack-plugin' packageName: 'autodll-webpack-plugin'
}) })
.target('dist/compiled/autodll-webpack-plugin') .target('dist/compiled/autodll-webpack-plugin')
...@@ -91,6 +103,18 @@ export async function ncc_autodll_webpack_plugin (task, opts) { ...@@ -91,6 +103,18 @@ export async function ncc_autodll_webpack_plugin (task, opts) {
notify('Compiled autodll-webpack-plugin') notify('Compiled autodll-webpack-plugin')
} }
// eslint-disable-next-line camelcase
export async function ncc_autodll_webpack_plugin_paths (task, opts) {
await task
.source(opts.src || relative(__dirname, require.resolve('autodll-webpack-plugin')))
.ncc({
externals: ['chokidar', 'webpack']
})
.target('dist/compiled/autodll-webpack-plugin/paths')
notify('Compiled autodll-webpack-plugin')
}
// eslint-disable-next-line camelcase // eslint-disable-next-line camelcase
export async function ncc_webpack_dev_middleware (task, opts) { export async function ncc_webpack_dev_middleware (task, opts) {
await task await task
...@@ -145,7 +169,7 @@ export async function ncc_text_table (task, opts) { ...@@ -145,7 +169,7 @@ export async function ncc_text_table (task, opts) {
} }
export async function precompile (task) { export async function precompile (task) {
await task.parallel(['ncc_webpack', 'ncc_webpack_graph_helpers', 'ncc_webpack_hot_middleware', 'ncc_autodll_webpack_plugin', 'ncc_webpack_dev_middleware', 'ncc_unistore', 'ncc_resolve', 'ncc_arg', 'ncc_nanoid', 'ncc_text_table']) await task.parallel(['ncc_webpack', 'ncc_webpack_NodeOutputFileSystem', 'ncc_webpack_graph_helpers', 'ncc_webpack_hot_middleware', 'ncc_autodll_webpack_plugin', 'ncc_autodll_webpack_plugin_paths', 'ncc_webpack_dev_middleware', 'ncc_unistore', 'ncc_resolve', 'ncc_arg', 'ncc_nanoid', 'ncc_text_table'])
} }
export async function compile (task) { export async function compile (task) {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment