From fa8c7741c757274780e1201da010337afb7a453e Mon Sep 17 00:00:00 2001 From: JJ Kasper Date: Mon, 21 Mar 2022 20:23:39 -0500 Subject: [PATCH] Update trace ignore check to check reasons correctly --- .../build/webpack/plugins/next-trace-entrypoints-plugin.ts | 4 +++- test/integration/production/pages/api/index.js | 6 +++--- test/integration/production/test/index.test.js | 2 +- 3 files changed, 7 insertions(+), 5 deletions(-) diff --git a/packages/next/build/webpack/plugins/next-trace-entrypoints-plugin.ts b/packages/next/build/webpack/plugins/next-trace-entrypoints-plugin.ts index 2f0e7ababae6..21b14ad40165 100644 --- a/packages/next/build/webpack/plugins/next-trace-entrypoints-plugin.ts +++ b/packages/next/build/webpack/plugins/next-trace-entrypoints-plugin.ts @@ -365,7 +365,9 @@ export class TraceEntryPointsPlugin implements webpack5.WebpackPluginInstance { // static image imports, CSS imports file = nodePath.join(this.tracingRoot, file) const depMod = depModMap.get(file) - const isAsset = reasons.get(file)?.type.includes('asset') + const isAsset = reasons + .get(nodePath.relative(this.tracingRoot, file)) + ?.type.includes('asset') return ( !isAsset && diff --git a/test/integration/production/pages/api/index.js b/test/integration/production/pages/api/index.js index 22e945b9672f..5df383f4a834 100644 --- a/test/integration/production/pages/api/index.js +++ b/test/integration/production/pages/api/index.js @@ -1,12 +1,12 @@ import fs from 'fs' import path from 'path' -import data from '../../static/hello.json' +import css from '../../components/logo/logo.module.css' export default (req, res) => { console.log({ - importedData: data, + importedData: css, fsLoadedData: fs.readFileSync( - path.join(process.cwd(), 'static', 'hello.json'), + path.join(process.cwd(), 'components', 'logo', 'logo.module.css'), 'utf8' ), }) diff --git a/test/integration/production/test/index.test.js b/test/integration/production/test/index.test.js index 5276dbf5db56..82c91a9acef1 100644 --- a/test/integration/production/test/index.test.js +++ b/test/integration/production/test/index.test.js @@ -225,7 +225,7 @@ describe('Production Usage', () => { }, { page: '/api', - tests: [/webpack-runtime\.js/, /static\/hello\.json/], + tests: [/webpack-runtime\.js/, /\/logo\.module\.css/], notTests: [ /next\/dist\/server\/next\.js/, /next\/dist\/bin/,