-
-
Notifications
You must be signed in to change notification settings - Fork 27
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #80 from davidmyersdev/77-missing-zlib-imports
Make sure all modules under `buffer` are exported
- Loading branch information
Showing
9 changed files
with
170 additions
and
4 deletions.
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,43 @@ | ||
// eslint-disable-next-line unicorn/prefer-node-protocol, n/no-deprecated-api | ||
import { Buffer, SlowBuffer, kMaxLength } from 'buffer' | ||
import { | ||
Blob, | ||
BlobOptions, | ||
Buffer, | ||
File, | ||
FileOptions, | ||
INSPECT_MAX_BYTES, | ||
// eslint-disable-next-line n/no-deprecated-api | ||
SlowBuffer, | ||
TranscodeEncoding, | ||
atob, | ||
btoa, | ||
constants, | ||
isAscii, | ||
isUtf8, | ||
kMaxLength, | ||
kStringMaxLength, | ||
resolveObjectURL, | ||
transcode, | ||
// eslint-disable-next-line unicorn/prefer-node-protocol | ||
} from 'buffer' | ||
|
||
export { | ||
Blob, | ||
BlobOptions, | ||
Buffer, | ||
File, | ||
FileOptions, | ||
INSPECT_MAX_BYTES, | ||
SlowBuffer, | ||
TranscodeEncoding, | ||
atob, | ||
btoa, | ||
constants, | ||
isAscii, | ||
isUtf8, | ||
kMaxLength, | ||
kStringMaxLength, | ||
resolveObjectURL, | ||
transcode, | ||
} | ||
|
||
export { Buffer, SlowBuffer, kMaxLength } | ||
export default Buffer |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
<!DOCTYPE html> | ||
<html lang="en"> | ||
<head> | ||
<meta charset="UTF-8" /> | ||
<meta name="viewport" content="width=device-width, initial-scale=1.0" /> | ||
<title>missing-zlib-imports</title> | ||
</head> | ||
<body> | ||
<div id="app"></div> | ||
<script type="module" src="/src/index.ts"></script> | ||
</body> | ||
</html> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
{ | ||
"name": "missing-zlib-imports", | ||
"type": "module", | ||
"version": "0.0.0", | ||
"private": true, | ||
"scripts": { | ||
"build": "vite build", | ||
"dev": "vite", | ||
"test:e2e": "CI=true run-p test:e2e:*", | ||
"test:e2e:build": "VITE_COMMAND=build WEB_SERVER_COMMAND='vite build && vite preview --port 15176' WEB_SERVER_URL='http://localhost:15176' playwright test", | ||
"test:e2e:dev": "VITE_COMMAND=dev WEB_SERVER_COMMAND='vite dev --port 15175' WEB_SERVER_URL='http://localhost:15175' playwright test" | ||
}, | ||
"dependencies": { | ||
"fast-zlib": "^2.0.1", | ||
"vite-plugin-node-polyfills": "workspace:*" | ||
}, | ||
"devDependencies": { | ||
"vite": "^5.1.1" | ||
} | ||
} |
29 changes: 29 additions & 0 deletions
29
test/error-repros/missing-zlib-imports/playwright.config.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
import { defineConfig, devices } from '@playwright/test' | ||
|
||
const webServerCommand = process.env.WEB_SERVER_COMMAND || 'pnpm dev' | ||
const webServerUrl = process.env.WEB_SERVER_URL || 'http://localhost:5173' | ||
|
||
// https://playwright.dev/docs/test-configuration | ||
export default defineConfig({ | ||
forbidOnly: !!process.env.CI, | ||
fullyParallel: true, | ||
projects: [ | ||
{ | ||
name: 'chromium', | ||
use: { ...devices['Desktop Chrome'] }, | ||
}, | ||
], | ||
reporter: 'html', | ||
retries: process.env.CI ? 2 : 0, | ||
testDir: './test/e2e', | ||
use: { | ||
baseURL: webServerUrl, | ||
trace: 'on-first-retry', | ||
}, | ||
webServer: { | ||
command: webServerCommand, | ||
stdout: 'ignore', | ||
url: webServerUrl, | ||
}, | ||
workers: process.env.CI ? 1 : undefined, | ||
}) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
import zlib from 'fast-zlib' | ||
|
||
// eslint-disable-next-line no-console | ||
console.log(Object.keys(zlib)) |
27 changes: 27 additions & 0 deletions
27
test/error-repros/missing-zlib-imports/test/e2e/main.spec.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
import { expect, test } from '@playwright/test' | ||
|
||
test('sets the page title', async ({ page }) => { | ||
await page.goto('/') | ||
|
||
await expect(page).toHaveTitle('missing-zlib-imports') | ||
}) | ||
|
||
test('logs the correct values', async ({ page }) => { | ||
const errors = [] | ||
const logs = [] | ||
|
||
page.on('console', (message) => { | ||
logs.push(message.text()) | ||
}) | ||
|
||
page.on('pageerror', (error) => { | ||
errors.push(error.message) | ||
}) | ||
|
||
await page.goto('/') | ||
|
||
expect(errors).toEqual([]) | ||
expect(logs).toContainEqual( | ||
'[Inflate, Deflate, InflateRaw, DeflateRaw, Gzip, Gunzip, Unzip, BrotliCompress, BrotliDecompress, constants, default]', | ||
) | ||
}) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
import { defineConfig } from 'vite' | ||
import { nodePolyfills } from 'vite-plugin-node-polyfills' | ||
|
||
// https://vitejs.dev/config/ | ||
export default defineConfig({ | ||
optimizeDeps: { | ||
force: true, | ||
}, | ||
plugins: [ | ||
nodePolyfills(), | ||
], | ||
}) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
import { defineConfig } from 'vitest/config' | ||
|
||
export default defineConfig({ | ||
test: { | ||
include: ['**/*.test.ts'], | ||
}, | ||
}) |