diff --git a/package-lock.json b/package-lock.json index 733133fa23..c4ef679fb2 100644 --- a/package-lock.json +++ b/package-lock.json @@ -5268,17 +5268,6 @@ "integrity": "sha512-w28IoSUCJpidD/TGviZwwMJckNESJZXFu7NBZ5YJ4mEUnNraUn9Pm8HSZm/jDF1pDWYKspWE7oVphigUPRakIQ==", "license": "MIT" }, - "node_modules/@types/glob": { - "version": "8.1.0", - "resolved": "https://registry.npmjs.org/@types/glob/-/glob-8.1.0.tgz", - "integrity": "sha512-IO+MJPVhoqz+28h1qLAcBEH2+xHMK6MTyHJc7MTnnYb6wsoLR29POVGJ7LycmVXIqyy/4/2ShP5sUwTXuOwb/w==", - "dev": true, - "license": "MIT", - "dependencies": { - "@types/minimatch": "^5.1.2", - "@types/node": "*" - } - }, "node_modules/@types/http-cache-semantics": { "version": "4.0.4", "resolved": "https://registry.npmjs.org/@types/http-cache-semantics/-/http-cache-semantics-4.0.4.tgz", @@ -5366,13 +5355,6 @@ "@types/lodash": "*" } }, - "node_modules/@types/minimatch": { - "version": "5.1.2", - "resolved": "https://registry.npmjs.org/@types/minimatch/-/minimatch-5.1.2.tgz", - "integrity": "sha512-K0VQKziLUWkVKiRVrx4a40iPaxTUefQmjtkQofBkYRcoaaL/8rhwDWww9qWbrgicNOgnpIsMxyNIUM4+n6dUIA==", - "dev": true, - "license": "MIT" - }, "node_modules/@types/minimist": { "version": "1.2.5", "resolved": "https://registry.npmjs.org/@types/minimist/-/minimist-1.2.5.tgz", @@ -12570,6 +12552,7 @@ "version": "1.0.0", "resolved": "https://registry.npmjs.org/fs.realpath/-/fs.realpath-1.0.0.tgz", "integrity": "sha512-OO0pH2lK6a0hZnAdau5ItzHPI6pUlvI7jMVnxUQRtw4owF2wk8lOSabtGDCTP4Ggrg2MbGnWO9X8K1t4+fGMDw==", + "dev": true, "license": "ISC" }, "node_modules/fsevents": { @@ -12997,26 +12980,6 @@ "ini": "^1.3.2" } }, - "node_modules/glob": { - "version": "8.1.0", - "resolved": "https://registry.npmjs.org/glob/-/glob-8.1.0.tgz", - "integrity": "sha512-r8hpEjiQEYlF2QU0df3dS+nxxSIreXQS1qRhMJM0Q5NDdR386C7jb7Hwwod8Fgiuex+k0GFjgft18yvxm5XoCQ==", - "deprecated": "Glob versions prior to v9 are no longer supported", - "license": "ISC", - "dependencies": { - "fs.realpath": "^1.0.0", - "inflight": "^1.0.4", - "inherits": "2", - "minimatch": "^5.0.1", - "once": "^1.3.0" - }, - "engines": { - "node": ">=12" - }, - "funding": { - "url": "https://github.com/sponsors/isaacs" - } - }, "node_modules/glob-parent": { "version": "5.1.2", "resolved": "https://registry.npmjs.org/glob-parent/-/glob-parent-5.1.2.tgz", @@ -13029,18 +12992,6 @@ "node": ">= 6" } }, - "node_modules/glob/node_modules/minimatch": { - "version": "5.1.6", - "resolved": "https://registry.npmjs.org/minimatch/-/minimatch-5.1.6.tgz", - "integrity": "sha512-lKwV/1brpG6mBUFHtb7NUmtABCb2WZZmm2wNiOA5hAb8VdCS4B3dtMWyvcoViccwAW/COERjXLt0zP1zXUN26g==", - "license": "ISC", - "dependencies": { - "brace-expansion": "^2.0.1" - }, - "engines": { - "node": ">=10" - } - }, "node_modules/global-cache-dir": { "version": "5.0.0", "resolved": "https://registry.npmjs.org/global-cache-dir/-/global-cache-dir-5.0.0.tgz", @@ -13801,6 +13752,7 @@ "resolved": "https://registry.npmjs.org/inflight/-/inflight-1.0.6.tgz", "integrity": "sha512-k92I/b08q4wvFscXCLvqfsHCrjrF7yiXsQuIVvVE7N82W3+aqpzuUdBbfhWcy/FZR3/4IgflMgKLOsvPDrGCJA==", "deprecated": "This module is not supported, and leaks memory. Do not use it. Check out lru-cache if you want a good and tested way to coalesce async requests by a key value, which is much more comprehensive and powerful.", + "dev": true, "license": "ISC", "dependencies": { "once": "^1.3.0", @@ -26430,10 +26382,9 @@ "es-module-lexer": "^1.0.0", "esbuild": "0.25.4", "execa": "^8.0.0", - "fast-glob": "^3.3.2", + "fast-glob": "^3.3.3", "filter-obj": "^6.0.0", "find-up": "^7.0.0", - "glob": "^8.0.3", "is-builtin-module": "^3.1.0", "is-path-inside": "^4.0.0", "junk": "^4.0.0", @@ -26459,7 +26410,6 @@ }, "devDependencies": { "@types/archiver": "6.0.3", - "@types/glob": "8.1.0", "@types/is-ci": "3.0.4", "@types/node": "20.12.11", "@types/normalize-path": "3.0.2", diff --git a/packages/zip-it-and-ship-it/package.json b/packages/zip-it-and-ship-it/package.json index 5c588032f8..f3f0c17559 100644 --- a/packages/zip-it-and-ship-it/package.json +++ b/packages/zip-it-and-ship-it/package.json @@ -52,10 +52,9 @@ "es-module-lexer": "^1.0.0", "esbuild": "0.25.4", "execa": "^8.0.0", - "fast-glob": "^3.3.2", + "fast-glob": "^3.3.3", "filter-obj": "^6.0.0", "find-up": "^7.0.0", - "glob": "^8.0.3", "is-builtin-module": "^3.1.0", "is-path-inside": "^4.0.0", "junk": "^4.0.0", @@ -78,7 +77,6 @@ }, "devDependencies": { "@types/archiver": "6.0.3", - "@types/glob": "8.1.0", "@types/is-ci": "3.0.4", "@types/node": "20.12.11", "@types/normalize-path": "3.0.2", diff --git a/packages/zip-it-and-ship-it/src/runtimes/node/bundlers/esbuild/bundler.ts b/packages/zip-it-and-ship-it/src/runtimes/node/bundlers/esbuild/bundler.ts index 7da997fa60..589bf50633 100644 --- a/packages/zip-it-and-ship-it/src/runtimes/node/bundlers/esbuild/bundler.ts +++ b/packages/zip-it-and-ship-it/src/runtimes/node/bundlers/esbuild/bundler.ts @@ -60,11 +60,13 @@ const includedFilesToEsbuildExternals = async (includedFiles: string[], baseDir: if (hasMultipleGlobs) { const resolved = await glob(pattern, { - noglobstar: true, + globstar: false, cwd: baseDir, }) - result.push(...resolved) + // esbuild expects relative paths to always have a leading `./` + const esbuildPatterns = resolved.map((pattern) => `./${pattern}`) + result.push(...esbuildPatterns) } else { result.push(pattern) } diff --git a/packages/zip-it-and-ship-it/src/runtimes/node/bundlers/nft/side_files.ts b/packages/zip-it-and-ship-it/src/runtimes/node/bundlers/nft/side_files.ts index 61c46e3fb7..911f3fe85e 100644 --- a/packages/zip-it-and-ship-it/src/runtimes/node/bundlers/nft/side_files.ts +++ b/packages/zip-it-and-ship-it/src/runtimes/node/bundlers/nft/side_files.ts @@ -17,8 +17,7 @@ export const getSideFiles = async function (functionPath: string, stat: Stats): const paths = await glob(`${functionPath}/**`, { absolute: true, cwd: functionPath, - ignore: `**/node_modules/**`, - nodir: true, + ignore: [`**/node_modules/**`], }) return paths.filter((path) => !isJunk(basename(path))) diff --git a/packages/zip-it-and-ship-it/src/runtimes/node/bundlers/zisi/published.ts b/packages/zip-it-and-ship-it/src/runtimes/node/bundlers/zisi/published.ts index ab977b5e22..c588731164 100644 --- a/packages/zip-it-and-ship-it/src/runtimes/node/bundlers/zisi/published.ts +++ b/packages/zip-it-and-ship-it/src/runtimes/node/bundlers/zisi/published.ts @@ -5,7 +5,6 @@ export const getPublishedFiles = async function (modulePath: string): Promise { - let normalizedIgnore - - if (options.ignore) { - normalizedIgnore = - typeof options.ignore === 'string' - ? normalizePath(options.ignore) - : options.ignore.map((expression) => normalizePath(expression)) - } - - return pGlob(normalizePath(pattern), { ...options, ignore: normalizedIgnore }) +export const glob = function (pattern: string, options: originalGlob.Options): Promise { + const normalizedIgnore = options.ignore?.map((expression) => normalizePath(expression)) + return originalGlob(normalizePath(pattern), { ...options, ignore: normalizedIgnore }) } export const minimatch = function (target: string, pattern: string, options?: MinimatchOptions): boolean { diff --git a/packages/zip-it-and-ship-it/tests/v2api.test.ts b/packages/zip-it-and-ship-it/tests/v2api.test.ts index fbd323cb06..1c15df6b90 100644 --- a/packages/zip-it-and-ship-it/tests/v2api.test.ts +++ b/packages/zip-it-and-ship-it/tests/v2api.test.ts @@ -1,13 +1,11 @@ import { readFile } from 'fs/promises' import { join, resolve } from 'path' -import { platform, version as nodeVersion } from 'process' -import { promisify } from 'util' +import { platform } from 'process' import { getPath as getBootstrapPath } from '@netlify/serverless-functions-api' import merge from 'deepmerge' -import glob from 'glob' +import glob from 'fast-glob' import { pathExists } from 'path-exists' -import semver from 'semver' import { dir as getTmpDir } from 'tmp-promise' import { afterEach, describe, expect, test, vi } from 'vitest' @@ -18,11 +16,9 @@ import { invokeLambda, readAsBuffer } from './helpers/lambda.js' import { zipFixture, unzipFiles, importFunctionFile, FIXTURES_ESM_DIR, FIXTURES_DIR } from './helpers/main.js' import { testMany } from './helpers/test_many.js' -const pGlob = promisify(glob) - vi.mock('../src/utils/shell.js', () => ({ shellUtils: { runCommand: vi.fn() } })) -describe.runIf(semver.gte(nodeVersion, '18.13.0'))('V2 functions API', () => { +describe('V2 functions API', () => { afterEach(() => { vi.resetAllMocks() }) @@ -132,7 +128,7 @@ describe.runIf(semver.gte(nodeVersion, '18.13.0'))('V2 functions API', () => { const [{ name: archive, entryFilename, path }] = files - const untranspiledFiles = await pGlob(`${path}/**/*.ts`) + const untranspiledFiles = await glob(`${path}/**/*.ts`) expect(untranspiledFiles).toEqual([]) const func = await importFunctionFile(`${tmpDir}/${archive}/${entryFilename}`)