-
Notifications
You must be signed in to change notification settings - Fork 25
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Fix Brotli compression #144
Changes from 14 commits
6303cc9
4080b3f
ae55300
252a403
d90bdcc
6e755dd
699f879
c95b8bc
380fd7c
fee18a2
6c5d024
870e78d
8b0ba53
1a8026c
9ddc9fb
5ec71df
c6c1900
23e281c
45be2f3
3d4146b
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
This file was deleted.
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
import path from 'node:path'; | ||
/** | ||
* this plugin resolves to a browser version of compression.ts that uses different code for browsers | ||
*/ | ||
export const compressionBrowserPlugin = { | ||
name: 'compressionBrowser', | ||
setup(build) { | ||
build.onResolve({ filter: /^\.\/compression$/ }, (args) => { | ||
return { path: path.join(args.resolveDir, args.path.replace('compression', 'browser/compression.ts')) }; | ||
}); | ||
}, | ||
}; |
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -3,24 +3,27 @@ | |
* It attaches the parquet.js exports to a "parquetjs" global variable. | ||
* See the example server for how to use it. | ||
*/ | ||
const { compressionBrowserPlugin, wasmPlugin } = require('./esbuild-plugins'); | ||
import { compressionBrowserPlugin } from './esbuild-plugins.mjs'; | ||
import watPlugin from 'esbuild-plugin-wat'; | ||
import esbuild from 'esbuild'; | ||
// esbuild has TypeScript support by default. It will use .tsconfig | ||
require('esbuild') | ||
esbuild | ||
.context({ | ||
entryPoints: ['parquet.ts'], | ||
outfile: 'main.js', | ||
define: { 'process.env.NODE_DEBUG': 'false', 'process.env.NODE_ENV': '"production"', global: 'window' }, | ||
platform: 'browser', | ||
plugins: [compressionBrowserPlugin, wasmPlugin], | ||
plugins: [compressionBrowserPlugin, watPlugin()], | ||
sourcemap: 'external', | ||
bundle: true, | ||
minify: false, | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Keeping minify off here for the local serve. |
||
globalName: 'parquetjs', | ||
inject: ['./esbuild-shims.js'], | ||
inject: ['./esbuild-shims.mjs'], | ||
}) | ||
.then((context) => { | ||
context | ||
.serve({ | ||
servedir: __dirname, | ||
servedir: './', | ||
}) | ||
.then((server) => { | ||
console.log('serving parquetjs', server); | ||
|
This file was deleted.
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. mjs conversion |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
import { Buffer as buffer } from 'buffer/'; | ||
export let Buffer = buffer; |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,6 @@ | ||
const esbuild = require('esbuild'); | ||
const path = require('path'); | ||
const { compressionBrowserPlugin, wasmPlugin } = require('./esbuild-plugins'); | ||
import esbuild from 'esbuild'; | ||
import watPlugin from 'esbuild-plugin-wat'; | ||
import { compressionBrowserPlugin } from './esbuild-plugins.mjs'; | ||
// esbuild has TypeScript support by default | ||
const baseConfig = { | ||
bundle: true, | ||
|
@@ -10,11 +10,11 @@ const baseConfig = { | |
'process.env.NODE_ENV': '"production"', | ||
global: 'window', | ||
}, | ||
inject: ['./esbuild-shims.js'], | ||
minify: true, | ||
inject: ['./esbuild-shims.mjs'], | ||
minify: false, | ||
mainFields: ['browser', 'module', 'main'], | ||
wilwade marked this conversation as resolved.
Show resolved
Hide resolved
|
||
platform: 'browser', // default | ||
plugins: [compressionBrowserPlugin, wasmPlugin], | ||
plugins: [compressionBrowserPlugin, watPlugin()], | ||
target: 'es2020', // default | ||
}; | ||
// configuration for generating test code in browser | ||
|
@@ -26,39 +26,53 @@ const testConfig = { | |
'process.env.NODE_ENV': '"production"', | ||
global: 'window', | ||
}, | ||
inject: ['./esbuild-shims.js'], | ||
inject: ['./esbuild-shims.mjs'], | ||
minify: false, | ||
mainFields: ['browser', 'module', 'main'], | ||
platform: 'browser', // default | ||
plugins: [compressionBrowserPlugin, wasmPlugin], | ||
plugins: [compressionBrowserPlugin, watPlugin()], | ||
target: 'es2020', // default | ||
}; | ||
const targets = [ | ||
{ | ||
...baseConfig, | ||
globalName: 'parquetjs', | ||
outdir: path.resolve(__dirname, 'dist', 'browser'), | ||
outdir: './dist/browser', | ||
}, | ||
{ | ||
...baseConfig, | ||
format: 'esm', | ||
outfile: path.resolve(__dirname, 'dist', 'browser', 'parquet.esm.js'), | ||
outfile: 'dist/browser/parquet.esm.js', | ||
}, | ||
{ | ||
...baseConfig, | ||
format: 'cjs', | ||
outfile: path.resolve(__dirname, 'dist', 'browser', 'parquet.cjs.js'), | ||
outfile: 'dist/browser/parquet.cjs.js', | ||
}, | ||
// Browser test code below | ||
]; | ||
|
||
// Browser test code below is only in ESM | ||
const testTargets = [ | ||
{ | ||
...testConfig, | ||
outfile: path.resolve(__dirname, 'test', 'browser', 'main.js'), | ||
format: 'esm', | ||
mainFields: ['module', 'main'], | ||
outfile: 'test/browser/main.js', | ||
}, | ||
]; | ||
|
||
Promise.all(targets.map(esbuild.build)) | ||
.then((results) => { | ||
if (results.reduce((m, r) => m && !r.warnings.length, true)) { | ||
console.log('built with no errors or warnings'); | ||
console.log('built dist targets with no errors or warnings'); | ||
} | ||
}) | ||
.then(() => { | ||
return Promise.all(testTargets.map(esbuild.build)); | ||
}) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This has to be after the other targets are built as it is dependent on it. |
||
.then((results) => { | ||
if (results.reduce((m, r) => m && !r.warnings.length, true)) { | ||
console.log('built test targets with no errors or warnings'); | ||
} | ||
}) | ||
.catch((e) => { | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Visible output! |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
mjs version swap and removing now unused wasm plugin