Skip to content

Commit a2cd4ff

Browse files
authored
Bug/browser types bug #70 (#71)
* Update esbuild * Allow running a specific test file * Build out types for the browser cjs and esm files * Update the README on how to use building
1 parent 73cf70d commit a2cd4ff

File tree

6 files changed

+217
-181
lines changed

6 files changed

+217
-181
lines changed

README.md

Lines changed: 41 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -27,23 +27,53 @@ _parquet.js requires node.js >= 14.16.0_
2727
$ npm install @dsnp/parquetjs
2828
```
2929

30-
### NodeJS
31-
To use with nodejs:
30+
### NodeJS
31+
To use with nodejs:
3232
```javascript
3333
import parquetjs from "@dsnp/parquetjs"
3434
```
3535

36-
### Browser
37-
To use in a browser, in your bundler, depending on your needs, write the appropriate plugin or resolver to point to:
36+
### Browser with Bundler
37+
To use in a browser with a bundler, depending on your needs, write the appropriate plugin or resolver to point to either the Common JS or ES Module version:
3838
```javascript
39-
"node_modules/@dsnp/parquetjs/browser/parquetjs"
39+
// Common JS
40+
"node_modules/@dsnp/parquetjs/dist/browser/parquetjs.cjs"
41+
// ES Modules
42+
"node_modules/@dsnp/parquetjs/dist/browser/parquetjs.esm"
4043
```
4144
or:
42-
4345
```javascript
44-
import parquetjs from "@dsnp/parquetjs/browser/parquetjs"
46+
// Common JS
47+
import parquetjs from "@dsnp/parquetjs/dist/browser/parquetjs.cjs"
48+
// ES Modules
49+
import parquetjs from "@dsnp/parquetjs/dist/browser/parquetjs.esm"
4550
```
4651

52+
### Browser Direct: ES Modules
53+
To use directly in the browser without a bundler using ES Modules:
54+
55+
1. Build the package: `npm install && npm run build:browser`
56+
2. Copy to `dist/browser/parquetjs.esm.js` the server
57+
3. Use it in your html or other ES Modules:
58+
```html
59+
<script type="module">
60+
import parquetjs from '../parquet.esm.js';
61+
// Use parquetjs
62+
</script>
63+
```
64+
65+
### Browser Direct: Plain Ol' JavaScript
66+
To use directly in the browser without a bundler or ES Modules:
67+
68+
1. Build the package: `npm install && npm run build:browser`
69+
2. Copy to `dist/browser/parquetjs.js` the server
70+
2. Use the global `parquetjs` variable to access parquetjs functions
71+
```html
72+
<script>
73+
// console.log(parquetjs)
74+
</script>
75+
```
76+
4777
## Usage: Writing files
4878

4979
Once you have installed the parquet.js library, you can import it as a single
@@ -74,7 +104,7 @@ compression.
74104

75105
Once we have a schema, we can create a `ParquetWriter` object. The writer will
76106
take input rows as JSON objects, convert them to the Parquet format and store
77-
them on disk.
107+
them on disk.
78108

79109
``` js
80110
// create new ParquetWriter that writes to 'fruits.parquet`
@@ -88,7 +118,7 @@ await writer.appendRow({name: 'oranges', quantity: 10, price: 2.5, date: new Dat
88118
Once we are finished adding rows to the file, we have to tell the writer object
89119
to flush the metadata to disk and close the file by calling the `close()` method:
90120

91-
### Adding bloom filters
121+
### Adding bloom filters
92122

93123
Bloom filters can be added to multiple columns as demonstrated below:
94124

@@ -207,7 +237,7 @@ let reader = await parquet.ParquetReader.openUrl(request,'https://domain/fruits.
207237
### Reading data from S3
208238

209239
Parquet files can be read from an S3 object without having to download the whole file.
210-
You will have to supply the aws-sdk client as first argument and the bucket/key information
240+
You will have to supply the aws-sdk client as first argument and the bucket/key information
211241
as second argument to the function `parquetReader.openS3`.
212242

213243
``` js
@@ -291,7 +321,7 @@ with a nested field, omit the `type` in the column definition and add a `fields`
291321
list instead:
292322

293323
Consider this example, which allows us to store a more advanced "fruits" table
294-
where each row contains a name, a list of colours and a list of "stock" objects.
324+
where each row contains a name, a list of colours and a list of "stock" objects.
295325

296326
``` js
297327
// advanced fruits table

browser/parquet.cjs.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
// Generates the types for the commonjs browser build
2+
3+
export * from "../parquet";

browser/parquet.esm.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
// Generates the types for the es modules browser build
2+
3+
export * from "../parquet";

0 commit comments

Comments
 (0)