Skip to content

Commit 8244f28

Browse files
authored
fix: remove swc binaries (#681)
* fix: remove swc binaries * fix: update test
1 parent 054b8d5 commit 8244f28

File tree

2 files changed

+11
-2
lines changed

2 files changed

+11
-2
lines changed

index.js

+9
Original file line numberDiff line numberDiff line change
@@ -125,6 +125,15 @@ See https://ntl.fyi/remove-plugin for instructions.
125125
publishDir: netlifyConfig.build.publish || PUBLISH_DIR,
126126
nextRoot,
127127
})
128+
129+
if (!netlifyConfig.functions['*'].included_files) {
130+
// eslint-disable-next-line no-param-reassign
131+
netlifyConfig.functions['*'].included_files = []
132+
}
133+
netlifyConfig.functions['*'].included_files.push(
134+
'!node_modules/@next/swc-*/**/*',
135+
'!node_modules/next/dist/compiled/@ampproject/toolbox-optimizer/**/*',
136+
)
128137
},
129138

130139
async onPostBuild({ netlifyConfig, packageJson, constants: { FUNCTIONS_DIST = DEFAULT_FUNCTIONS_DIST }, utils }) {

test/index.js

+2-2
Original file line numberDiff line numberDiff line change
@@ -87,7 +87,7 @@ afterEach(async () => {
8787
})
8888

8989
const DUMMY_PACKAGE_JSON = { name: 'dummy', version: '1.0.0', scripts: { build: 'next build' } }
90-
const netlifyConfig = { build: { command: 'npm run build' } }
90+
const netlifyConfig = { build: { command: 'npm run build' }, functions: { '*': {} } }
9191

9292
describe('preBuild()', () => {
9393
test('fails if the build version is too old', () => {
@@ -307,7 +307,7 @@ describe('onBuild()', () => {
307307
await moveNextDist()
308308
const PUBLISH_DIR = 'publish'
309309
await plugin.onBuild({
310-
netlifyConfig: { build: { publish: path.resolve(PUBLISH_DIR), command: 'next build' } },
310+
netlifyConfig: { ...netlifyConfig, build: { publish: path.resolve(PUBLISH_DIR), command: 'next build' } },
311311
packageJson: DUMMY_PACKAGE_JSON,
312312
constants: {
313313
PUBLISH_DIR,

0 commit comments

Comments
 (0)