|
1 |
| -const { writeJSON, unlink, existsSync, readFileSync, copy } = require('fs-extra') |
| 1 | +const { writeJSON, unlink, existsSync, readFileSync, copy, ensureDir } = require('fs-extra') |
2 | 2 | const path = require('path')
|
3 | 3 | const process = require('process')
|
4 | 4 |
|
@@ -42,9 +42,18 @@ const onBuildHasRun = (netlifyConfig) =>
|
42 | 42 |
|
43 | 43 | // Move .next from sample project to current directory
|
44 | 44 | const moveNextDist = async function () {
|
| 45 | + await stubModules(['next', 'react', 'react-dom', 'sharp']) |
45 | 46 | await copy(path.join(SAMPLE_PROJECT_DIR, '.next'), path.join(process.cwd(), '.next'))
|
46 | 47 | }
|
47 | 48 |
|
| 49 | +const stubModules = async function (modules) { |
| 50 | + for (const mod of modules) { |
| 51 | + const dir = path.join(process.cwd(), 'node_modules', mod) |
| 52 | + await ensureDir(dir) |
| 53 | + await writeJSON(path.join(dir, 'package.json'), { name: mod }) |
| 54 | + } |
| 55 | +} |
| 56 | + |
48 | 57 | // Copy fixture files to the current directory
|
49 | 58 | const useFixture = async function (fixtureName) {
|
50 | 59 | const fixtureDir = `${FIXTURES_DIR}/${fixtureName}`
|
@@ -185,15 +194,15 @@ describe('onBuild()', () => {
|
185 | 194 | '.next/serverless/**',
|
186 | 195 | '.next/*.json',
|
187 | 196 | '.next/BUILD_ID',
|
188 |
| - '!node_modules/@next/swc-*/**/*', |
189 |
| - '!node_modules/next/dist/compiled/@ampproject/toolbox-optimizer/**/*', |
| 197 | + '!../node_modules/next/dist/compiled/@ampproject/toolbox-optimizer/**/*', |
190 | 198 | '!node_modules/next/dist/pages/**/*',
|
191 | 199 | `!node_modules/next/dist/server/lib/squoosh/**/*.wasm`,
|
192 | 200 | `!node_modules/next/dist/next-server/server/lib/squoosh/**/*.wasm`,
|
193 |
| - '!node_modules/next/dist/compiled/webpack/(bundle4|bundle5).js', |
| 201 | + '!node_modules/next/dist/compiled/webpack/bundle4.js', |
| 202 | + '!node_modules/next/dist/compiled/webpack/bundle5.js', |
| 203 | + '!node_modules/next/dist/compiled/terser/bundle.min.js', |
194 | 204 | '!node_modules/react/**/*.development.js',
|
195 | 205 | '!node_modules/react-dom/**/*.development.js',
|
196 |
| - '!node_modules/use-subscription/**/*.development.js', |
197 | 206 | '!node_modules/sharp/**/*',
|
198 | 207 | ]
|
199 | 208 | expect(netlifyConfig.functions[HANDLER_FUNCTION_NAME].included_files).toEqual(includes)
|
|
0 commit comments