Skip to content
This repository has been archived by the owner on May 22, 2024. It is now read-only.

Commit

Permalink
chore: use const instead of hardcoded strings (#1462)
Browse files Browse the repository at this point in the history
  • Loading branch information
danez authored Jun 12, 2023
1 parent 16e49d9 commit 47c0b97
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 7 deletions.
6 changes: 5 additions & 1 deletion tests/esbuild.test.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import { build } from '@netlify/esbuild'
import { afterEach, describe, expect, test, vi } from 'vitest'

import { ARCHIVE_FORMAT } from '../src/archive.js'
import { NODE_BUNDLER } from '../src/runtimes/node/bundlers/types.js'

import { zipFixture } from './helpers/main.js'
Expand Down Expand Up @@ -30,7 +31,10 @@ describe('esbuild', () => {
// - in Node <10 we should see `try {} catch (e) {}`
// - in Node >= 10 we should see `try {} catch {}`
await zipFixture('node-module-optional-catch-binding', {
opts: { archiveFormat: 'none', config: { '*': { nodeBundler: NODE_BUNDLER.ESBUILD, nodeVersion: '18.x' } } },
opts: {
archiveFormat: ARCHIVE_FORMAT.NONE,
config: { '*': { nodeBundler: NODE_BUNDLER.ESBUILD, nodeVersion: '18.x' } },
},
})

expect(build).toHaveBeenCalledWith(expect.objectContaining({ target: ['node18'] }))
Expand Down
9 changes: 5 additions & 4 deletions tests/main.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ import { dir as getTmpDir, tmpName } from 'tmp-promise'
import unixify from 'unixify'
import { afterAll, afterEach, beforeAll, describe, expect, test, vi } from 'vitest'

import { ARCHIVE_FORMAT } from '../src/archive.js'
import { ESBUILD_LOG_LIMIT } from '../src/runtimes/node/bundlers/esbuild/bundler.js'
import { NODE_BUNDLER } from '../src/runtimes/node/bundlers/types.js'
import { detectEsModule } from '../src/runtimes/node/utils/detect_es_module.js'
Expand Down Expand Up @@ -305,7 +306,7 @@ describe('zip-it-and-ship-it', () => {
const length = 4
const fixtureName = 'local-require-esm'
const opts = merge(options, {
archiveFormat: 'none' as const,
archiveFormat: ARCHIVE_FORMAT.NONE,
basePath: join(FIXTURES_DIR, fixtureName),
config: {
'*': {
Expand Down Expand Up @@ -1201,7 +1202,7 @@ describe('zip-it-and-ship-it', () => {

testMany('Generates a directory if `archiveFormat` is set to `none`', [...allBundleConfigs], async (options) => {
const opts = merge(options, {
archiveFormat: 'none' as const,
archiveFormat: ARCHIVE_FORMAT.NONE,
})
const { files } = await zipNode('node-module-included', {
opts,
Expand Down Expand Up @@ -1574,7 +1575,7 @@ describe('zip-it-and-ship-it', () => {
const fixtureName = 'node-module-dynamic-import-4'
const { tmpDir } = await zipNode(fixtureName, {
opts: {
archiveFormat: 'none',
archiveFormat: ARCHIVE_FORMAT.NONE,
basePath: join(FIXTURES_DIR, fixtureName),
config: { '*': { nodeBundler: NODE_BUNDLER.ESBUILD } },
},
Expand Down Expand Up @@ -2180,7 +2181,7 @@ describe('zip-it-and-ship-it', () => {
const basePath = join(FIXTURES_DIR, fixtureName)
const { files } = await zipFixture(fixtureName, {
opts: {
archiveFormat: 'none',
archiveFormat: ARCHIVE_FORMAT.NONE,
basePath,
config: { '*': { nodeBundler: NODE_BUNDLER.NFT, nodeSourcemap: true } },
},
Expand Down
4 changes: 2 additions & 2 deletions tests/zip_function.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import { dir as getTmpDir } from 'tmp-promise'
import unixify from 'unixify'
import { describe, expect, test } from 'vitest'

import { NODE_BUNDLER, zipFunction } from '../src/main.js'
import { ARCHIVE_FORMAT, NODE_BUNDLER, zipFunction } from '../src/main.js'

import { FIXTURES_DIR, getBundlerNameFromOptions, importFunctionFile, unzipFiles } from './helpers/main.js'
import { allBundleConfigs, getNodeBundlerString, testMany } from './helpers/test_many.js'
Expand Down Expand Up @@ -83,7 +83,7 @@ describe('zipFunction', () => {
await writeFile(testFilePath, 'module.exports = true')

await zipFunction(`${FIXTURES_DIR}/simple/function.js`, tmpDir, {
archiveFormat: 'none',
archiveFormat: ARCHIVE_FORMAT.NONE,
})

const functionEntry = await importFunctionFile(`${functionDirectory}/function.js`)
Expand Down

1 comment on commit 47c0b97

@github-actions
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⏱ Benchmark results

  • largeDepsEsbuild: 2.5s
  • largeDepsNft: 8.1s
  • largeDepsZisi: 16.2s

Please sign in to comment.