Skip to content

Commit

Permalink
some more cleanup
Browse files Browse the repository at this point in the history
  • Loading branch information
lev875 committed Oct 22, 2023
1 parent a2366b8 commit 08d23e2
Show file tree
Hide file tree
Showing 11 changed files with 31 additions and 26 deletions.
9 changes: 0 additions & 9 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -46,15 +46,6 @@
"files": "*.test.js",
"rules": {
"n/no-extraneous-require": "off"
},
"globals": {
"describe": "readonly",
"it": "readonly",
"expect": "readonly",
"beforeAll": "readonly",
"beforeEach": "readonly",
"afterEach": "readonly",
"jest": "readonly"
}
},
{
Expand Down
2 changes: 1 addition & 1 deletion packages/esbuild/test/fixtures/cjs/big.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
require('redux')
require('redux/lib/redux')
require('../file')
require('./file')
2 changes: 1 addition & 1 deletion packages/esbuild/test/fixtures/cjs/esbuild.config.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
const { join } = require('path')

module.exports = {
entryPoints: [join(__dirname, '../file.js'), join(__dirname, '../small.js')],
entryPoints: [join(__dirname, 'file.js'), join(__dirname, 'small.js')],
outdir: join(process.cwd(), 'dist'),
bundle: true,
minify: false
Expand Down
File renamed without changes.
File renamed without changes.
2 changes: 1 addition & 1 deletion packages/esbuild/test/fixtures/esm/esbuild.config.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { join } from 'path'

export default {
entryPoints: [join(__dirname, '../file.js'), join(__dirname, '../small.js')],
entryPoints: [join(__dirname, 'file.js'), join(__dirname, 'small.js')],
outdir: join(process.cwd(), 'dist'),
bundle: true,
minify: false
Expand Down
5 changes: 5 additions & 0 deletions packages/esbuild/test/fixtures/esm/file.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
console.log('11111111111')
console.log('11111111111')
console.log('11111111111')
console.log('11111111111')
console.log('11111111111')
3 changes: 3 additions & 0 deletions packages/esbuild/test/fixtures/esm/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{
"type": "module"
}
1 change: 1 addition & 0 deletions packages/esbuild/test/fixtures/esm/small.js
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
console.log('111111111111111111111')
28 changes: 14 additions & 14 deletions packages/esbuild/test/index.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ it('uses esbuild to make bundle', async () => {
esbuildMetafile: config.checks[0].esbuildMetafile,
esbuildOutfile: config.checks[0].esbuildOutfile,
files: [fixture('cjs/big.js')],
size: 2286
size: 2140
}
]
})
Expand All @@ -69,7 +69,7 @@ it('supports ignore', async () => {
checks: [{ files: fixture('cjs/big.js'), ignore: ['redux'] }]
}
await run(config)
expect(config.checks[0].size).toBe(439)
expect(config.checks[0].size).toBe(237)
})

describe('supports custom esbuild config', () => {
Expand All @@ -79,7 +79,7 @@ describe('supports custom esbuild config', () => {
configPath: ROOT_CONFIG
}
await run(config)
expect(config.checks[0].size).toBe(163)
expect(config.checks[0].size).toBe(490)
})

it('should work with esm config', async () => {
Expand All @@ -88,7 +88,7 @@ describe('supports custom esbuild config', () => {
configPath: ROOT_CONFIG
}
await run(config)
expect(config.checks[0].size).toBe(163)
expect(config.checks[0].size).toBe(166)
})
})

Expand All @@ -99,7 +99,7 @@ describe('supports custom entry', () => {
configPath: ROOT_CONFIG
}
await run(config)
expect(config.checks[0].size).toBe(66)
expect(config.checks[0].size).toBe(229)
})

it('should work with esm config', async () => {
Expand All @@ -108,7 +108,7 @@ describe('supports custom entry', () => {
configPath: ROOT_CONFIG
}
await run(config)
expect(config.checks[0].size).toBe(66)
expect(config.checks[0].size).toBe(68)
})
})

Expand Down Expand Up @@ -149,20 +149,20 @@ it('allows to disable esbuild', async () => {
checks: [{ esbuild: false, files: [fixture('cjs/big.js')] }]
}
await run(config)
expect(config.checks[0].size).toBe(56)
expect(config.checks[0].size).toBe(55)
})

it('allows to disable gzip', async () => {
let config = {
checks: [{ files: [fixture('small.js')], gzip: false }]
checks: [{ files: [fixture('esm/small.js')], gzip: false }]
}
await run(config)
expect(config.checks[0].size).toBe(37)
})

it('throws on missed file plugin', async () => {
let config = {
checks: [{ files: [fixture('small.js')] }]
checks: [{ files: [fixture('cjs/small.js')] }]
}
try {
await esbuild.step20(config, config.checks[0])
Expand All @@ -181,7 +181,7 @@ it('throws on missed file plugin', async () => {

it('supports --save-bundle', async () => {
let config = {
checks: [{ files: [fixture('small.js')] }],
checks: [{ files: [fixture('cjs/small.js')] }],
saveBundle: DIST
}
await run(config)
Expand All @@ -191,7 +191,7 @@ it('supports --save-bundle', async () => {
it('supports --clean-dir', async () => {
let dist = join(DIST, 'small.js')
let config = {
checks: [{ files: [fixture('small.js')] }],
checks: [{ files: [fixture('cjs/small.js')] }],
cleanDir: true,
saveBundle: DIST
}
Expand All @@ -206,7 +206,7 @@ it('supports --clean-dir', async () => {
it('throws error on not empty bundle dir', async () => {
let dist = join(DIST, 'small.js')
let config = {
checks: [{ files: [fixture('small.js')] }],
checks: [{ files: [fixture('cjs/small.js')] }],
saveBundle: DIST
}
await run(config)
Expand All @@ -225,7 +225,7 @@ it('throws error on not empty bundle dir', async () => {
it('throws unsupported error --save-bundle', async () => {
let distFile = join(DIST, 'small.js')
let config = {
checks: [{ files: [fixture('small.js')] }],
checks: [{ files: [fixture('cjs/small.js')] }],
saveBundle: distFile
}
await mkdir(DIST)
Expand Down Expand Up @@ -262,7 +262,7 @@ it('can use `modifyEsbuildConfig` for resolution of aliases', async () => {
return config
}
})
).toBe(2286)
).toBe(2140)
})

it('supports specifying the import', async () => {
Expand Down
5 changes: 5 additions & 0 deletions vite.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,5 +6,10 @@ export default defineConfig({
provider: 'istanbul',
statements: 100,
},
watchExclude: [
'**/fixtures',
'**/dist',
'**/out',
],
},
})

0 comments on commit 08d23e2

Please sign in to comment.