Webpack 5 Adoption #23498
Replies: 67 comments 102 replies
-
This is important. webpack/webpack#12868 |
Beta Was this translation helpful? Give feedback.
-
An issue I'm having with next-auth and webpack5 outlined here. nextauthjs/next-auth#1611 |
Beta Was this translation helpful? Give feedback.
-
Using the future flag, the build fails (including next dev and other runtimes)
|
Beta Was this translation helpful? Give feedback.
-
This error occurs when running
It seems like this only happens when |
Beta Was this translation helpful? Give feedback.
-
I'm getting this warning message when using Webpack 5:
|
Beta Was this translation helpful? Give feedback.
-
Next.js team how you guys tested the reduced installation size? Bundle size have increased, and I'm sure this is one of the reasons why some people are having build memory issues.
With
|
Beta Was this translation helpful? Give feedback.
-
Using webpack(config) in next.config.js throws an error after enabling webpack5
next.config.js attached for reference. We need next-images, and certain webpack config like fs, net, tls to be disabled.
Reproductionnpx create-next-app |
Beta Was this translation helpful? Give feedback.
-
A reproduction
Confignext.config.js:const withPreact = require("next-plugin-preact");
module.exports = withPreact({
/* regular next.js config options here */
future: {
webpack5: true,
},
}); package.json:{
"name": "using-preact",
"version": "1.0.0",
"scripts": {
"dev": "next",
"build": "next build",
"start": "next start"
},
"devDependencies": {},
"dependencies": {
"next": "^10.0.0",
"next-plugin-preact": "^3.0.3",
"preact": "^10.5.5",
"preact-render-to-string": "^5.1.11",
"react": "npm:@preact/compat@^0.0.3",
"react-dom": "npm:@preact/compat@^0.0.3",
"react-ssr-prepass": "npm:preact-ssr-prepass@^1.1.2"
},
"license": "MIT"
}
OS:
Node:Tried Images |
Beta Was this translation helpful? Give feedback.
-
Any solution for this on windows?
|
Beta Was this translation helpful? Give feedback.
This comment has been hidden.
This comment has been hidden.
This comment has been hidden.
This comment has been hidden.
-
After switching to the
When opening this file locally I see this code
I tried hard coding the version like
|
Beta Was this translation helpful? Give feedback.
-
Trying to update my project to the latest next@10.1.1 with webpack5 and getting the following build error:
|
Beta Was this translation helpful? Give feedback.
-
With these lines in the webpack config of
I get the following error when running
|
Beta Was this translation helpful? Give feedback.
This comment has been hidden.
This comment has been hidden.
-
I'm using custom error pages (_error.js and 404.js). With Next 10.2.3 after build in static/chunks/main.js file I had no code from default error page (https://github.com/vercel/next.js/blob/fa01a1593e4ba56357c04bcb506e5e41b038d836/packages/next/pages/_error.tsx). The question is how can I opt out code from default error page? I have custom ones and don't want redundant code in the bundle. |
Beta Was this translation helpful? Give feedback.
-
I'm getting this error when using Is there any workaround to this? Strangely, it works when I use |
Beta Was this translation helpful? Give feedback.
-
Upgraded from Next 10 to 11.1.2 and now get the following error when I npm run dev: (node:36208) [DEP_WEBPACK_EXTERNALS_FUNCTION_PARAMETERS] DeprecationWarning: The externals-function should be defined like ({context, request}, cb) => { ... } package.json next.config.js
|
Beta Was this translation helpful? Give feedback.
-
I am working on upgrading to webpack 5 and am stuck on an error: I am using, from package.json:
In next.config.js, we use:
and in our config there we have:
The error I see:
Has anyone encountered with SassError? Advice appreciated! |
Beta Was this translation helpful? Give feedback.
-
Upgrading from Next 11 to Next 12Please Helpthrows this error in the browser console, and every page becomes white.
|
Beta Was this translation helpful? Give feedback.
-
There seems to be a bug with Next and Webpack 5 when running certain dynamic import code in dev mode. See https://github.com/edew/nextjs-webpack-module-bug for a minimal reproduction. |
Beta Was this translation helpful? Give feedback.
-
when running npm run dev, it throws error next.config.js package.json |
Beta Was this translation helpful? Give feedback.
-
Hi. I updated my project to Next.js 12 and activated the Webpack to version 5. And now > Build error occurred
ValidationError: Invalid configuration object. Webpack has been initialized using a configuration object that does not match the API schema.
- configuration.module.rules[5] should be one of these:
["..." | object { assert?, compiler?, dependency?, descriptionData?, enforce?, exclude?, generator?, include?, issuer?, issuerLayer?, layer?, loader?, mimetype?, oneOf?, options?, parser?, realResource?, resolve?, resource?, resourceFragment?, resourceQuery?, rules?, scheme?, sideEffects?, test?, type?, use? }, ...]
-> A rule.
Details:
* configuration.module.rules[5].loader should be a non-empty string.
-> A loader request.
at validate (/Users/brunodulcetti/repositories/mosaico/cupom/site/node_modules/next/dist/compiled/schema-utils3/index.js:1:153662)
at validateSchema (/Users/brunodulcetti/repositories/mosaico/cupom/site/node_modules/next/dist/compiled/webpack/bundle5.js:130764:2)
at create (/Users/brunodulcetti/repositories/mosaico/cupom/site/node_modules/next/dist/compiled/webpack/bundle5.js:134244:24)
at webpack (/Users/brunodulcetti/repositories/mosaico/cupom/site/node_modules/next/dist/compiled/webpack/bundle5.js:134291:32)
at Object.f [as webpack] (/Users/brunodulcetti/repositories/mosaico/cupom/site/node_modules/next/dist/compiled/webpack/bundle5.js:89548:16)
at /Users/brunodulcetti/repositories/mosaico/cupom/site/node_modules/next/dist/build/compiler.js:31:40
at new Promise (<anonymous>)
at Object.runCompiler (/Users/brunodulcetti/repositories/mosaico/cupom/site/node_modules/next/dist/build/compiler.js:30:12)
at /Users/brunodulcetti/repositories/mosaico/cupom/site/node_modules/next/dist/build/index.js:374:59
at Span.traceAsyncFn (/Users/brunodulcetti/repositories/mosaico/cupom/site/node_modules/next/dist/trace/trace.js:74:26) {
errors: [
{
keyword: 'oneOf',
dataPath: '.module.rules',
schemaPath: '#/properties/rules/oneOf',
params: [Object],
message: 'should match exactly one schema in oneOf',
schema: [Array],
parentSchema: [Object],
data: [Array],
children: [Array]
}
],
schema: {
definitions: {
Amd: [Object],
AssetFilterItemTypes: [Object],
AssetFilterTypes: [Object],
AssetGeneratorDataUrl: [Object],
AssetGeneratorDataUrlFunction: [Object],
AssetGeneratorDataUrlOptions: [Object],
AssetGeneratorOptions: [Object],
AssetInlineGeneratorOptions: [Object],
AssetModuleFilename: [Object],
AssetParserDataUrlFunction: [Object],
AssetParserDataUrlOptions: [Object],
AssetParserOptions: [Object],
AssetResourceGeneratorOptions: [Object],
AuxiliaryComment: [Object],
Bail: [Object],
CacheOptions: [Object],
CacheOptionsNormalized: [Object],
Charset: [Object],
ChunkFilename: [Object],
ChunkFormat: [Object],
ChunkLoadTimeout: [Object],
ChunkLoading: [Object],
ChunkLoadingGlobal: [Object],
ChunkLoadingType: [Object],
Clean: [Object],
CleanOptions: [Object],
CompareBeforeEmit: [Object],
Context: [Object],
CrossOriginLoading: [Object],
Dependencies: [Object],
DevServer: [Object],
DevTool: [Object],
DevtoolFallbackModuleFilenameTemplate: [Object],
DevtoolModuleFilenameTemplate: [Object],
DevtoolNamespace: [Object],
EmptyGeneratorOptions: [Object],
EmptyParserOptions: [Object],
EnabledChunkLoadingTypes: [Object],
EnabledLibraryTypes: [Object],
EnabledWasmLoadingTypes: [Object],
Entry: [Object],
EntryDescription: [Object],
EntryDescriptionNormalized: [Object],
EntryDynamic: [Object],
EntryDynamicNormalized: [Object],
EntryFilename: [Object],
EntryItem: [Object],
EntryNormalized: [Object],
EntryObject: [Object],
EntryRuntime: [Object],
EntryStatic: [Object],
EntryStaticNormalized: [Object],
EntryUnnamed: [Object],
Environment: [Object],
Experiments: [Object],
ExperimentsCommon: [Object],
ExperimentsNormalized: [Object],
ExternalItem: [Object],
ExternalItemFunctionData: [Object],
ExternalItemValue: [Object],
Externals: [Object],
ExternalsPresets: [Object],
ExternalsType: [Object],
FileCacheOptions: [Object],
Filename: [Object],
FilenameTemplate: [Object],
FilterItemTypes: [Object],
FilterTypes: [Object],
GeneratorOptionsByModuleType: [Object],
GlobalObject: [Object],
HashDigest: [Object],
HashDigestLength: [Object],
HashFunction: [Object],
HashSalt: [Object],
HotUpdateChunkFilename: [Object],
HotUpdateGlobal: [Object],
HotUpdateMainFilename: [Object],
HttpUriAllowedUris: [Object],
HttpUriOptions: [Object],
HttpUriOptionsAllowedUris: [Object],
IgnoreWarnings: [Object],
IgnoreWarningsNormalized: [Object],
Iife: [Object],
ImportFunctionName: [Object],
ImportMetaName: [Object],
InfrastructureLogging: [Object],
JavascriptParserOptions: [Object],
Layer: [Object],
LazyCompilationDefaultBackendOptions: [Object],
LazyCompilationOptions: [Object],
Library: [Object],
LibraryCustomUmdCommentObject: [Object],
LibraryCustomUmdObject: [Object],
LibraryExport: [Object],
LibraryName: [Object],
LibraryOptions: [Object],
LibraryType: [Object],
Loader: [Object],
MemoryCacheOptions: [Object],
Mode: [Object],
ModuleFilterItemTypes: [Object],
ModuleFilterTypes: [Object],
ModuleOptions: [Object],
ModuleOptionsNormalized: [Object],
Name: [Object],
NoParse: [Object],
Node: [Object],
NodeOptions: [Object],
Optimization: [Object],
OptimizationRuntimeChunk: [Object],
OptimizationRuntimeChunkNormalized: [Object],
OptimizationSplitChunksCacheGroup: [Object],
OptimizationSplitChunksGetCacheGroups: [Object],
OptimizationSplitChunksOptions: [Object],
OptimizationSplitChunksSizes: [Object],
Output: [Object],
OutputModule: [Object],
OutputNormalized: [Object],
Parallelism: [Object],
ParserOptionsByModuleType: [Object],
Path: [Object],
Pathinfo: [Object],
Performance: [Object],
PerformanceOptions: [Object],
Plugins: [Object],
Profile: [Object],
PublicPath: [Object],
RawPublicPath: [Object],
RecordsInputPath: [Object],
RecordsOutputPath: [Object],
RecordsPath: [Object],
Resolve: [Object],
ResolveAlias: [Object],
ResolveLoader: [Object],
ResolveOptions: [Object],
ResolvePluginInstance: [Object],
RuleSetCondition: [Object],
RuleSetConditionAbsolute: [Object],
RuleSetConditionOrConditions: [Object],
RuleSetConditionOrConditionsAbsolute: [Object],
RuleSetConditions: [Object],
RuleSetConditionsAbsolute: [Object],
RuleSetLoader: [Object],
RuleSetLoaderOptions: [Object],
RuleSetLogicalConditions: [Object],
RuleSetLogicalConditionsAbsolute: [Object],
RuleSetRule: [Object],
RuleSetRules: [Object],
RuleSetUse: [Object],
RuleSetUseItem: [Object],
ScriptType: [Object],
SnapshotOptions: [Object],
SourceMapFilename: [Object],
SourcePrefix: [Object],
StatsOptions: [Object],
StatsValue: [Object],
StrictModuleErrorHandling: [Object],
StrictModuleExceptionHandling: [Object],
Target: [Object],
TrustedTypes: [Object],
UmdNamedDefine: [Object],
UniqueName: [Object],
WarningFilterItemTypes: [Object],
WarningFilterTypes: [Object],
WasmLoading: [Object],
WasmLoadingType: [Object],
Watch: [Object],
WatchOptions: [Object],
WebassemblyModuleFilename: [Object],
WebpackOptionsNormalized: [Object],
WebpackPluginFunction: [Object],
WebpackPluginInstance: [Object]
},
title: 'WebpackOptions',
description: 'Options object as provided by the user.',
type: 'object',
additionalProperties: false,
properties: {
amd: [Object],
bail: [Object],
cache: [Object],
context: [Object],
dependencies: [Object],
devServer: [Object],
devtool: [Object],
entry: [Object],
experiments: [Object],
externals: [Object],
externalsPresets: [Object],
externalsType: [Object],
ignoreWarnings: [Object],
infrastructureLogging: [Object],
loader: [Object],
mode: [Object],
module: [Object],
name: [Object],
node: [Object],
optimization: [Object],
output: [Object],
parallelism: [Object],
performance: [Object],
plugins: [Object],
profile: [Object],
recordsInputPath: [Object],
recordsOutputPath: [Object],
recordsPath: [Object],
resolve: [Object],
resolveLoader: [Object],
snapshot: [Object],
stats: [Object],
target: [Object],
watch: [Object],
watchOptions: [Object]
}
},
headerName: 'Webpack',
baseDataPath: 'configuration',
postFormatter: [Function: postFormatter]
}
error Command failed with exit code 1. The fifth index of rules follows below: {
test: /\.+(js|jsx|mjs|ts|tsx)$/,
loader: {
loader: 'next-swc-loader',
options: {
isServer: true,
pagesDir: '/Users/brunodulcetti/repositories/mosaico/cupom/site/src/pages',
hasReactRefresh: false,
fileReading: true,
nextConfig: [Object],
jsConfig: [Object]
}
},
include: [Function (anonymous)]
} next.config.js const path = require('path');
const nextEnv = require('next-env');
const withPlugins = require('next-compose-plugins');
const withTM = require('next-transpile-modules')([
'@asteroid/analytics',
'@asteroid/components',
'@asteroid/icons',
'@asteroid/shared',
]);
const withNextEnv = nextEnv({
staticPrefix: 'BRAND',
});
const {BRAND} = process.env;
const securityHeaders = [
{
key: 'X-Frame-Options',
value: 'SAMEORIGIN',
},
];
const nextConfig = {
images: {
domains: ['s.zst.com.br'],
},
webpack: config => {
config.resolve.alias = {
...config.resolve.alias,
'@asteroid/theme': path.resolve(
__dirname,
`node_modules/@asteroid/components/src/theme/${BRAND}/`,
),
'@theme': path.resolve(__dirname, 'src/theme/'),
};
config.module.rules.push({
test: /\.svg$/i,
issuer: /\.(js|ts|md)x?$/,
use: [
{
loader: '@svgr/webpack',
options: {
prettier: false,
svgo: true,
svgoConfig: {plugins: [{removeViewBox: false}]},
titleProp: true,
},
},
],
});
return config;
},
basePath: '/cupom-de-desconto',
eslint: {
ignoreDuringBuilds: true,
},
staticPageGenerationTimeout: 120,
compress: true,
async headers() {
return [
{
source: '/:all*(svg|jpg|png)',
locale: false,
headers: [
{
key: 'Cache-Control',
value: 'public, max-age=300, must-revalidate',
},
],
},
{
source: '/:path*',
headers: securityHeaders,
},
];
},
};
module.exports = withPlugins([[[withNextEnv]], [withTM]], nextConfig); package.json {
"name": "cupom-front",
"version": "0.0.20",
"scripts": {
"dev": "NODE_OPTIONS='--inspect' next dev",
"dev:zoom": "NEXT_PUBLIC_BRAND=zoom BRAND=zoom yarn dev",
"prod:zoom": "NEXT_PUBLIC_BRAND=zoom BRAND=zoom next build",
"dev:buscape": "NEXT_PUBLIC_BRAND=buscape BRAND=buscape yarn dev",
"prod:buscape": "NEXT_PUBLIC_BRAND=buscape BRAND=buscape next build",
"build": "next build",
"start": "next start",
"postbuild": "next-sitemap"
},
"dependencies": {
"@asteroid/analytics": "^3.51.0",
"@asteroid/components": "^3.51.0",
"@asteroid/icons": "^3.51.0",
"@asteroid/shared": "3.51.0",
"@chakra-ui/icons": "^1.0.13",
"@chakra-ui/react": "^1.4.2",
"@chakra-ui/theme-tools": "1.1.2",
"@emotion/react": "11.1.5",
"@emotion/styled": "11.1.5",
"@fontsource/montserrat": "^4.3.0",
"bootstrap": "4.4.1",
"classnames": "^2.3.1",
"cross-fetch": "^3.1.4",
"currency.js": "^1.2.2",
"framer-motion": "^4.0.3",
"js-cookie": "^3.0.1",
"jwt-simple": "^0.5.6",
"lodash": "^4.17.21",
"moment": "^2.29.1",
"newrelic": "^7.5.2",
"next": "12.0.7",
"next-compose-plugins": "^2.2.1",
"next-env": "^1.1.1",
"next-seo": "^4.24.0",
"next-transpile-modules": "^6.4.0",
"node-cache": "^5.1.2",
"node-sass": "4.14.1",
"nookies": "^2.5.2",
"react": "^17.0.2",
"react-bootstrap": "^1.6.3",
"react-clamp-lines": "^3.0.2",
"react-dom": "^17.0.2",
"react-instantsearch-core": "^6.12.1",
"react-lite-youtube-embed": "^2.2.2",
"react-modal": "^3.14.3",
"react-multi-carousel": "^2.8.2",
"react-rating": "^2.0.5",
"react-responsive-carousel": "^3.2.21",
"react-share": "^4.4.0",
"react-swipeable": "^7.0.0",
"react-tabs": "^3.2.2",
"snarkdown": "^2.0.0",
"styled-components": "^5.3.5"
},
"devDependencies": {
"@asteroid/eslint-config": "^3.51.0",
"@asteroid/prettier-config": "^3.51.0",
"@asteroid/stylelint-config": "^3.51.0",
"@svgr/webpack": "^5.5.0",
"@testing-library/jest-dom": "^5.16.5",
"@testing-library/react": "^13.3.0",
"@testing-library/react-hooks": "^8.0.1",
"@testing-library/user-event": "^14.4.3",
"@types/node": "^14.6.0",
"@types/react": "^17.0.3",
"@types/react-dom": "^17.0.3",
"@types/styled-components": "^5.1.26",
"@typescript-eslint/eslint-plugin": "^4.28.2",
"@typescript-eslint/parser": "^4.28.2",
"babel-eslint": "^10.1.0",
"eslint": "^7.30.0",
"eslint-config-airbnb": "^18.2.1",
"eslint-config-next": "^11.0.1",
"eslint-config-prettier": "^8.3.0",
"eslint-plugin-import": "^2.23.4",
"eslint-plugin-jsx-a11y": "^6.4.1",
"eslint-plugin-prettier": "^3.4.0",
"eslint-plugin-react": "^7.24.0",
"eslint-plugin-react-hooks": "^4.2.0",
"file-loader": "^6.2.0",
"next-sitemap": "^1.6.124",
"prettier": "^2.3.2",
"typescript": "4.3.2"
},
"license": "MIT",
"resolutions": {
"@types/react": "^17.0.3",
"@types/react-dom": "^17.0.3",
"styled-components": "^5"
}
} |
Beta Was this translation helpful? Give feedback.
-
Have upgraded to Next v12 and webpack 5 and am getting similar errors.
package.json
next.config.js
yarn dev and yarn start errors
|
Beta Was this translation helpful? Give feedback.
-
When will this message be removed? Can I hide it? I have OCD. |
Beta Was this translation helpful? Give feedback.
-
I'm using nextjs latest 13.4.19. I'm getting this warning: (node:48056) [DEP_WEBPACK_MODULE_UPDATE_HASH] DeprecationWarning: Module.updateHash: Use new ChunkGraph API Can you recommend how to find out what is causing this? Running commands from webpack cli doesn't work. |
Beta Was this translation helpful? Give feedback.
-
I got an error while trying to launch "npm run dev" Next -v: Next.js v10.2.3 Here is:
|
Beta Was this translation helpful? Give feedback.
-
Updating Next.js from version 10 to version 11 ([hash_id].webpack hot-update.json not found)SummaryReact pages are failing to load, and I've encountered a console error linked to the "[hash_id].webpack hot-update.json" file. The application is attempting to locate the file at We've been utilizing a custom Express server, and I'm providing the code snippet below. Your assistance in resolving this issue is urgently needed due to a security vulnerability raised by a client. Please advise on how to rectify this situation promptly. next.config.js require('dotenv').config()
const { withSentryConfig } = require('@sentry/nextjs')
const webpack = require('webpack')
const Dotenv = require('dotenv-webpack')
const withImages = require('next-images')
const devMode = process.env.NODE_ENV !== 'production'
const withTM = require('next-transpile-modules')([
'toasted-notes',
'load-google-maps-api',
'winston',
'logform',
'async',
'readable-stream',
'winston-transport',
'is-stream'
])
const { ANALYZE } = process.env
const SentryWebpackPluginOptions = {
silent: !!devMode
}
module.exports = withSentryConfig(
withTM(
withImages({
webpack5: true,
productionBrowserSourceMaps: true,
future: {
strictPostcssConfiguration: true
},
poweredByHeader: false,
async rewrites () {
return [
{
source: '/admin/api/emails',
destination: '/api/emails'
},
{
source: '/admin/api/auth/development',
destination: '/api/auth/development'
},
{
source: '/admin/api/auth/heartbeat',
destination: '/api/auth/heartbeat'
},
{
source: '/admin/api/auth/logout',
destination: '/api/auth/logout'
}
]
},
webpack: function (config, { isServer, buildId }) {
if (ANALYZE && devMode) {
const { BundleAnalyzerPlugin } = require('webpack-bundle-analyzer')
config.plugins.push(
new BundleAnalyzerPlugin({
analyzerMode: 'server',
analyzerPort: isServer ? 8888 : 8889,
openAnalyzer: true
})
)
}
config.module.rules.push(
{
test: /\.woff(\?v=\d+\.\d+\.\d+)?$/,
use: [
{
loader: 'url-loader?limit=10000&mimetype=application/font-woff',
options: {}
}
]
},
{
test: /\.woff2(\?v=\d+\.\d+\.\d+)?$/,
use: [
{
loader: 'url-loader?limit=10000&mimetype=application/font-woff',
options: {}
}
]
},
{
test: /\.ttf(\?v=\d+\.\d+\.\d+)?$/,
use: [
{
loader:
'url-loader?limit=10000&mimetype=application/octet-stream',
options: {}
}
]
},
{
test: /\.eot(\?v=\d+\.\d+\.\d+)?$/,
use: [
{
loader: 'file-loader',
options: {}
}
]
},
{
test: /\.svg(\?v=\d+\.\d+\.\d+)?$/,
use: [
{
loader: 'url-loader?limit=10000&mimetype=image/svg+xml',
options: {}
}
]
}
)
config.plugins.push(
new Dotenv({
path: './.env',
systemvars: true
}),
new webpack.DefinePlugin({
'process.env.BUILD_ID': JSON.stringify(buildId)
}),
new webpack.ProvidePlugin({
$: 'jquery',
jQuery: 'jquery'
})
)
return config
}
})
), SentryWebpackPluginOptions
) server.js const isProd = process.env.NODE_ENV === 'production'
const express = require('express')
const next = require('next')
const app = next({ dev: !isProd, dir: './src' })
const handle = app.getRequestHandler()
const bodyParser = require('body-parser')
const cookieParser = require('cookie-parser')
const morgan = require('morgan')
const winston = require('./integrations/winston')
const nextI18NextMiddleware = require('next-i18next/middleware').default
const nextI18next = require('./i18n')
const helmet = require('helmet')
const { join } = require('path');
app.prepare()
.then(() => {
const server = express()
server.use(morgan((tokens, req, res) => {
const object = {}
object['@timestamp'] = tokens['date'](req, res, 'iso')
object.status = tokens.status(req, res)
object.method = tokens.method(req, res)
object.url = `${req.protocol}://${req.headers.host}${tokens.url(req, res)}`
object.responseTime = tokens['response-time'](req, res)
object.contentLength = tokens['res'](req, res, 'content-length')
object.headers = req.headers
return JSON.stringify(object)
}, {
stream: winston.stream
}))
server.use(bodyParser.json())
server.use(cookieParser())
server.use(nextI18NextMiddleware(nextI18next))
// CSP needs to be implemented
server.use(helmet({
contentSecurityPolicy: false
}))
// Disable SSL check for dev env for now.
const isLocal = process.env.NODE_ENV !== 'production'
if (isLocal) process.env.NODE_TLS_REJECT_UNAUTHORIZED = '0'
server
// Regular next.js request handler
.use(handle)
.listen(3000, err => {
if (err) {
throw err
}
// eslint-disable-next-line no-console
console.log('> Ready on http://localhost:3000')
})
})
.catch((ex) => {
console.error(ex.stack)
process.exit(1)
}) Package json {
"name": "fe",
"license": "ISC",
"scripts": {
"analyze": "ANALYZE=1 yarn build",
"build": "NODE_OPTIONS=--max_old_space_size=5120 next build src",
"commit": "cz",
"commitlint": "commitlint --edit $1",
"cypress:open": "cypress open",
"cypress:run": "percy exec -- cypress run",
"cypress:ci": "start-server-and-test dev http://localhost:3000/admin/login cypress:run",
"dev": "NODE_EXTRA_CA_CERTS='/usr/local/share/ca-certificates/myCA.pem' nodemon --inspect=0.0.0.0:9229 src/server.js",
"format:ts": "prettier --write './**/*.{ts,tsx}' --config ./.prettierrc",
"generate:hoc": "hygen hoc new --resource",
"generate:integration": "hygen integration new --resource",
"generate:lib": "hygen lib new --resource",
"generate:model": "hygen model new --resource",
"generate:redux": "hygen redux new --resource",
"generate:type": "hygen type new --resource",
"lint:js": "standard --fix",
"lint:ts": "eslint './**/*.{ts,tsx}' --fix",
"release": "release-it",
"start": "NODE_ENV=production node src/server.js",
"test": "jest",
"test:watch": "jest --watch",
"prepare": "husky install"
},
"config": {
"commitizen": {
"path": "./node_modules/cz-conventional-changelog"
}
},
"dependencies": {
"@ant-design/icons": "4.7.0",
"@arcgis/core": "^4.26.5",
"@chakra-ui/core": "^0.8.0",
"@emotion/cache": "^10.0.19",
"@emotion/core": "^10.0.35",
"@emotion/react": "^11.4.1",
"@emotion/styled": "^10.0.27",
"@itsfadnis/jsonapi-client": "^3.0.2",
"@mui/icons-material": "^5.1.0",
"@mui/material": "^5.1.0",
"@sentry/nextjs": "^6.17.6",
"@sentry/react": "^6.17.6",
"@testing-library/cypress": "^7.0.5",
"@wojtekmaj/enzyme-adapter-react-17": "^0.6.7",
"autoprefixer": "^10.3.4",
"basic-auth": "^2.0.1",
"body-parser": "^1.19.0",
"classnames": "^2.2.6",
"cookie-parser": "^1.4.5",
"core-js": "^3.6.5",
"cropperjs": "^1.5.12",
"cypress": "7.3.0",
"dayjs": "^1.10.7",
"dotenv-webpack": "^8.0.1",
"dragula": "^3.7.3",
"emotion-theming": "^10.0.27",
"enzyme": "3.9.0",
"enzyme-to-json": "^3.5.0",
"express": "^4.17.1",
"file-loader": "^5.0.0",
"he": "^1.2.0",
"helmet": "^4.6.0",
"http-proxy-middleware": "^2.0.6",
"humps": "^2.0.1",
"immer": "9.0.6",
"jquery": "^3.5.1",
"js-cookie": "^2.2.1",
"json2mjml": "^1.0.3",
"kitsu": "^9.1.19",
"leaflet": "^1.7.1",
"leaflet-draw": "^1.0.4",
"load-google-maps-api": "^2.0.2",
"lodash": "^4.17.20",
"logrocket": "^1.0.14",
"mapbox-gl": "^1.12.0",
"mapbox-gl-leaflet": "^0.0.13",
"mapbox.js": "^3.3.1",
"mjml": "^4.12.0",
"mjml-validator": "^4.10.1",
"mjml2json": "^1.0.1",
"morgan": "^1.10.0",
"next": "11.1.3",
"next-i18next": "^2.0.1",
"next-images": "1.1.1",
"next-transpile-modules": "^8.0.0",
"node-fetch": "^2.6.1",
"node-html-parser": "^6.1.5",
"nookies": "^2.5.2",
"postcss": "^8.4.8",
"postcss-flexbugs-fixes": "^4.2.1",
"postcss-preset-env": "^6.7.0",
"prop-types": "^15.7.2",
"react": "^17.0.2",
"react-color": "^2.18.1",
"react-dom": "^17.0.2",
"react-flatpickr": "^3.10.6",
"react-frame-component": "^4.1.3",
"react-froala-wysiwyg": "^3.2.2",
"react-highlight-words": "^0.16.0",
"react-imgix": "^9.0.2",
"react-intercom": "^1.0.15",
"react-lazyload": "^3.0.0",
"react-places-autocomplete": "^7.3.0",
"react-player": "^2.6.2",
"react-redux": "^7.2.1",
"react-select": "^5.2.2",
"react-slick": "^0.27.11",
"react-test-renderer": "^17.0.2",
"redux": "^4.1.2",
"redux-thunk": "^2.3.0",
"sanitize-html": "^2.7.0",
"spectrum-colorpicker": "^1.8.1",
"tailwindcss": "^2.2.17",
"tsscmp": "^1.0.6",
"typescript": "^4.3.5",
"ui": "bangthetable/ui#v2.1.0",
"unsplash-js": "^7.0.15",
"url-loader": "^1.1.2",
"winston": "^3.3.3"
},
"devDependencies": {
"@commitlint/cli": "13.2.0",
"@commitlint/config-conventional": "^12.1.4",
"@commitlint/config-lerna-scopes": "^16.2.2",
"@percy/cli": "^1.0.0-beta.52",
"@percy/cypress": "^3.1.1",
"@types/basic-auth": "^1.1.3",
"@types/humps": "^2.0.1",
"@types/jest": "^27.0.2",
"@types/lodash": "^4.14.170",
"@types/mjml": "^4.7.0",
"@types/node": "^14.14.2",
"@types/react": "^17.0.2",
"@types/react-color": "^3.0.5",
"@types/react-dom": "^17.0.9",
"@types/react-redux": "^7.1.16",
"@types/redux": "^3.6.31",
"@types/redux-thunk": "^2.1.32",
"@types/sanitize-html": "^2.6.2",
"@types/styled-jsx": "^2.2.9",
"@types/tsscmp": "^1.0.0",
"@typescript-eslint/eslint-plugin": "^4.28.0",
"@typescript-eslint/parser": "^4.29.1",
"babel-eslint": "^10.1.0",
"babel-plugin-import": "^1.13.3",
"babel-plugin-module-resolver": "^4.1.0",
"cypress-iframe": "^1.0.1",
"cz-conventional-changelog": "^3.3.0",
"eslint": "^7.29.0",
"eslint-config-prettier": "^8.3.0",
"eslint-plugin-jsx-a11y": "^6.4.1",
"eslint-plugin-prettier": "^3.4.0",
"eslint-plugin-react": "^7.24.0",
"eslint-plugin-react-hooks": "^4.2.0",
"eslint-plugin-simple-import-sort": "^7.0.0",
"husky": "^7.0.0",
"hygen": "^6.1.0",
"jest": "^26.6.3",
"lint-staged": "^11.0.0",
"nodemon": "^2.0.7",
"prettier": "^2.3.1",
"redux-devtools-extension": "^2.13.9",
"redux-mock-store": "^1.5.4",
"release-it": "^14.10.1",
"standard": "^12.0.1",
"start-server-and-test": "^1.12.5",
"ts-jest": "^27.0.7",
"webpack-bundle-analyzer": "^4.9.1"
},
"engines": {
"node": "15.11.0",
"yarn": "^1.22.1"
},
"resolutions": {
"styled-jsx": "3.0.0",
"@babel/parser": "7.7.5",
"react-spring": "8.0.4",
"@types/react": "17.0.2",
"@types/react-dom": "17.0.2"
},
"standard": {
"parser": "babel-eslint",
"globals": [
"atob",
"HTMLCanvasElement",
"fetch",
"describe",
"FormData",
"expect",
"it",
"jest",
"beforeEach",
"afterEach",
"localStorage",
"test",
"Blob",
"$",
"confirm",
"MetisMenu",
"xit"
]
}
} Additional informationFolder structure : -
app -
- next.config.js
- src
- pages
- component
- server.js The GET request for ExampleNo response |
Beta Was this translation helpful? Give feedback.
-
Hi, is there am option to add node:{global:false} to next.config.mjs?
In this base webpack config i tried putting options like |
Beta Was this translation helpful? Give feedback.
-
I'm using some external code in my application to compile latex. I've downloaded the code from this repo: https://github.com/SwiftLaTeX/SwiftLaTeX however when I use this code in my own application I get this error: 'SyntaxError: Cannot use 'import.meta' outside a module (at swiftlatexdvipdfm.a31b1cfc.js:3587:24)'. This is my next.config.js right now, I've tried to change it a couple of times, using varying webpack configurations, however this has not fixed the issue so right now my next.config.js is looking like this: `// @ts-check /**
const nextConfig = { export default nextConfig` This is my package.json:
There are some points in the js code in the project where import.meta.url is used however this is not my code so I'm not sure how to fix this, I've downloaded the code and inserted into my project as there was no npm package. Below is the code the error realtes to:
How can I fix this error, is there a way to change my next.config.js/mjs so that this is resolved, thanks. |
Beta Was this translation helpful? Give feedback.
-
This discussion is for getting help when your application does not compile when using the new webpack 5 support.
Please make sure your comment includes:
next.config.js
andpackage.json
If these are not included your comment will likely be not actionable.
Beta Was this translation helpful? Give feedback.
All reactions