Skip to content

Commit

Permalink
Revert "feat: warn about large function bundles (#3831)" (#3849)
Browse files Browse the repository at this point in the history
This reverts commit 994695c.

Co-authored-by: Eduardo Bouças <[email protected]>
Co-authored-by: kodiakhq[bot] <49736102+kodiakhq[bot]@users.noreply.github.com>
  • Loading branch information
3 people authored Nov 17, 2021
1 parent 1177871 commit 9dedbcf
Show file tree
Hide file tree
Showing 5 changed files with 1 addition and 104 deletions.
22 changes: 1 addition & 21 deletions packages/build/src/log/messages/core_steps.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

const path = require('path')

const { log, logArray, logErrorSubHeader, logWarningSubHeader, logMessage } = require('../logger')
const { log, logArray, logErrorSubHeader, logWarningSubHeader } = require('../logger')
const { THEME } = require('../theme')

const logBundleResultFunctions = ({ functions, headerMessage, logs, error }) => {
Expand All @@ -17,24 +17,6 @@ const logBundleResultFunctions = ({ functions, headerMessage, logs, error }) =>
logArray(logs, functionNames)
}

const MAX_AWS_ZIP_SIZE = 50000000

const logSizeWarnings = ({ results, logs }) => {
const oversizedFunctions = results.filter(({ size }) => size > MAX_AWS_ZIP_SIZE)
oversizedFunctions.forEach(({ name, bundler }) => {
logErrorSubHeader(logs, `Function ${name} exceeds size limit of 50mb`)

if (bundler === 'zisi') {
logMessage(logs, `You're using the default bundler, and could benefit from esbuild: https://ntl.fyi/try-esbuild`)
} else {
logMessage(
logs,
`To debug, run \`$ netlify build\` locally and examine the contents of .netlify/functions/${name}.zip`,
)
}
})
}

const logBundleResults = ({ logs, results = [] }) => {
const resultsWithErrors = results.filter(({ bundlerErrors }) => bundlerErrors && bundlerErrors.length !== 0)
const resultsWithWarnings = results.filter(
Expand Down Expand Up @@ -65,8 +47,6 @@ const logBundleResults = ({ logs, results = [] }) => {
if (modulesWithDynamicImports.length !== 0) {
logModulesWithDynamicImports({ logs, modulesWithDynamicImports })
}

logSizeWarnings({ results, logs })
}

const logFunctionsNonExistingDir = function (logs, relativeFunctionsSrc) {
Expand Down

This file was deleted.

53 changes: 0 additions & 53 deletions packages/build/tests/core/snapshots/tests.js.md
Original file line number Diff line number Diff line change
Expand Up @@ -2299,56 +2299,3 @@ Generated by [AVA](https://avajs.dev).
────────────────────────────────────────────────────────────────␊
(Netlify Build completed in 1ms)`

## Shows notice about zip size being too big

> Snapshot 1
`␊
────────────────────────────────────────────────────────────────␊
Netlify Build ␊
────────────────────────────────────────────────────────────────␊
> Version␊
@netlify/build 1.0.0␊
> Flags␊
debug: true␊
repositoryRoot: packages/build/tests/core/fixtures/zip_too_big␊
testOpts:␊
pluginsListUrl: test␊
silentLingeringProcesses: true␊
> Current directory␊
packages/build/tests/core/fixtures/zip_too_big␊
> Config file␊
No config file was defined: using default values.␊
> Resolved config␊
build:␊
publish: packages/build/tests/core/fixtures/zip_too_big␊
publishOrigin: default␊
functionsDirectory: packages/build/tests/core/fixtures/zip_too_big/netlify/functions␊
> Context␊
production␊
────────────────────────────────────────────────────────────────␊
1. Functions bundling ␊
────────────────────────────────────────────────────────────────␊
Packaging Functions from netlify/functions directory:␊
- foo.js␊
> Function foo exceeds size limit of 1msb␊
You're using the default bundler, and could benefit from esbuild: https://ntl.fyi/try-esbuild␊
(Functions bundling completed in 1ms)␊
────────────────────────────────────────────────────────────────␊
Netlify Build Complete ␊
────────────────────────────────────────────────────────────────␊
(Netlify Build completed in 1ms)`
Binary file modified packages/build/tests/core/snapshots/tests.js.snap
Binary file not shown.
23 changes: 0 additions & 23 deletions packages/build/tests/core/tests.js
Original file line number Diff line number Diff line change
Expand Up @@ -433,29 +433,6 @@ test('Shows notice about modules with dynamic imports and suggests the usage of
await runFixture(t, 'esbuild_errors_2')
})

const generate250mbFile = async (path) => {
await pWriteFile(
path,
// eslint-disable-next-line no-magic-numbers
`module.exports = '${Array.from({ length: 5000000 })
// eslint-disable-next-line no-magic-numbers
.map(() => Math.random().toFixed(50))
.join('')}'`,
)
}

test('Shows notice about zip size being too big', async (t) => {
const veryLargeFile = join(__dirname, 'fixtures', 'zip_too_big', 'veryLargeFile.js')

try {
await generate250mbFile(veryLargeFile)

await runFixture(t, 'zip_too_big')
} finally {
await pUnlink(veryLargeFile)
}
})

test('Bundles functions from the `.netlify/functions-internal` directory', async (t) => {
await runFixture(t, 'functions_internal')
})
Expand Down

0 comments on commit 9dedbcf

Please sign in to comment.