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 ansi-html dep #6394

Merged
merged 1 commit into from
Feb 21, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Remove ansi-html dep
  • Loading branch information
timneutkens committed Feb 21, 2019
commit 2a3bc7c8406e8dbd35c62552ba430c5fbcf44285
2 changes: 1 addition & 1 deletion packages/next/build/webpack-config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ export default function getBaseWebpackConfig (dir: string, {dev = false, isServe
target: isServer ? 'node' : 'web',
externals: isServer && target !== 'serverless' ? [
(context, request, callback) => {
const notExternalModules = ['next/app', 'next/document', 'next/link', 'next/router', 'next/error', 'http-status', 'string-hash', 'ansi-html', 'hoist-non-react-statics', 'htmlescape']
const notExternalModules = ['next/app', 'next/document', 'next/link', 'next/router', 'next/error', 'http-status', 'string-hash', 'hoist-non-react-statics', 'htmlescape']

if (notExternalModules.indexOf(request) !== -1) {
return callback()
Expand Down
1 change: 0 additions & 1 deletion packages/next/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,6 @@
"@babel/runtime": "7.1.2",
"@babel/runtime-corejs2": "7.1.2",
"@babel/template": "7.1.2",
"ansi-html": "0.0.7",
"arg": "3.0.0",
"async-sema": "2.1.4",
"autodll-webpack-plugin": "0.4.2",
Expand Down
29 changes: 2 additions & 27 deletions packages/next/server/error-debug.js
Original file line number Diff line number Diff line change
@@ -1,21 +1,14 @@
import React from 'react'
import ansiHTML from 'ansi-html'
import Head from 'next-server/head'

// This component is rendered through dev-error-overlay on the client side.
// On the server side it's rendered directly
// This component is only rendered on the server side.
export default function ErrorDebug ({ error, info }) {
const { name, message } = error
return (
<div style={styles.errorDebug}>
<Head>
<meta name='viewport' content='width=device-width, initial-scale=1.0' />
</Head>
{
name === 'ModuleBuildError' && message
? <pre style={styles.stack} dangerouslySetInnerHTML={{ __html: ansiHTML(encodeHtml(message)) }} />
: <StackTrace error={error} info={info} />
}
<StackTrace error={error} info={info} />
</div>
)
}
Expand Down Expand Up @@ -68,21 +61,3 @@ export const styles = {
marginTop: '0px'
}
}

const encodeHtml = str => {
return str.replace(/</g, '&lt;').replace(/>/g, '&gt;')
}

// see color definitions of babel-code-frame:
// https://github.com/babel/babel/blob/master/packages/babel-code-frame/src/index.js

ansiHTML.setColors({
reset: ['6F6767', '0e0d0d'],
darkgrey: '6F6767',
yellow: '6F6767',
green: 'ebe7e5',
magenta: 'ebe7e5',
blue: 'ebe7e5',
cyan: 'ebe7e5',
red: 'ff001f'
})
4 changes: 2 additions & 2 deletions test/integration/basic/test/client-navigation.js
Original file line number Diff line number Diff line change
Expand Up @@ -663,7 +663,7 @@ export default (context) => {
})

describe('runtime errors', () => {
it('should show ErrorDebug when a client side error is thrown inside a component', async () => {
it('should show react-error-overlay when a client side error is thrown inside a component', async () => {
let browser
try {
browser = await webdriver(context.appPort, '/error-inside-browser-page')
Expand All @@ -678,7 +678,7 @@ export default (context) => {
}
})

it('should show ErrorDebug when a client side error is thrown outside a component', async () => {
it('should show react-error-overlay when a client side error is thrown outside a component', async () => {
let browser
try {
browser = await webdriver(context.appPort, '/error-in-the-browser-global-scope')
Expand Down