Skip to content

Commit b23a9e2

Browse files
committed
Add other exports
1 parent 0dd1089 commit b23a9e2

6 files changed

Lines changed: 30 additions & 22 deletions

File tree

crates/string-offsets/.gitignore

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
11
node_modules
22
pkg
3-
3+
.tgz

crates/string-offsets/CONTRIBUTING.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,10 +7,10 @@ The code for the wasm + js wrapper package is stored in the `js` directory. To b
77
```sh
88
cd js
99
npm i
10-
npm run build
10+
npm run compile
1111
```
1212

13-
The npm package will be output to `js/pkg`.
13+
The js code will be output to `js/pkg`.
1414

1515
To run a quick sanity check of the JS package:
1616

@@ -21,6 +21,6 @@ npm test
2121
To publish the package to npm, run:
2222

2323
```sh
24-
cd js/pkg
24+
cd js
2525
npm publish
2626
```

crates/string-offsets/Cargo.toml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,11 +8,12 @@ repository = "https://github.com/github/rust-gems"
88
license = "MIT"
99
keywords = ["unicode", "positions", "utf16", "characters", "lines"]
1010
categories = ["algorithms", "data-structures", "text-processing", "development-tools::ffi"]
11+
exclude = ["/js"]
1112

1213
[lib]
1314
crate-type = ["cdylib", "rlib"]
1415

15-
[dependencies]
16+
[target.'cfg(target_arch = "wasm32")'.dependencies]
1617
wasm-bindgen = "0.2"
1718

1819
[dev-dependencies]
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
/*
2+
!/pkg
3+
pkg/*/package.json
4+
pkg/*/README.md
Lines changed: 18 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,31 +1,34 @@
11
{
22
"name": "string-offsets-dev",
3-
"private": true,
43
"version": "0.1.0",
4+
"author": "The blackbird team <support@github.com>",
5+
"license": "MIT",
56
"description": "String offset conversions between UTF-8, UTF-16, and lines",
6-
"main": "pkg/string_offsets_js.js",
7-
"types": "pkg/string_offsets_js.d.ts",
8-
"files": [
9-
"./pkg/string_offsets_js_bg.wasm",
10-
"./pkg/string_offsets_js.d.ts",
11-
"./pkg/string_offsets_js.js"
12-
],
13-
"scripts": {
14-
"build": "wasm-pack build --target nodejs --out-dir js/pkg",
15-
"test": "jest"
16-
},
177
"keywords": [
188
"string",
199
"utf8",
2010
"utf16",
2111
"wasm",
2212
"rust"
2313
],
24-
"author": "",
25-
"license": "MIT",
14+
"main": "pkg/nodejs/string_offsets.js",
15+
"types": "pkg/nodejs/string_offsets.d.ts",
16+
"exports": {
17+
"bundler": "./pkg/bundler/string_offsets.js",
18+
"node": "./pkg/nodejs/string_offsets.js",
19+
"import": "./pkg/web/string_offsets.js",
20+
"require": "./pkg/nodejs/string_offsets.js"
21+
},
22+
"scripts": {
23+
"compile:bundler": "wasm-pack build --target bundler -d js/pkg/bundler && node -e \"fs.unlinkSync('./pkg/bundler/.gitignore')\"",
24+
"compile:web": "wasm-pack build --target web -d js/pkg/web && node -e \"fs.unlinkSync('./pkg/web/.gitignore')\"",
25+
"compile:nodejs": "wasm-pack build --target nodejs -d js/pkg/nodejs && node -e \"fs.unlinkSync('./pkg/nodejs/.gitignore')\"",
26+
"compile": "npm run compile:web && npm run compile:bundler && npm run compile:nodejs",
27+
"test": "jest"
28+
},
2629
"devDependencies": {
2730
"@types/jest": "^29.5.14",
2831
"jest": "^29.0.0",
2932
"wasm-pack": "^0.13.1"
3033
}
31-
}
34+
}

crates/string-offsets/js/test/test.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
//@ts-check
2-
const { StringOffsets } = require('../pkg/string_offsets.js');
3-
2+
const { StringOffsets } = require('../');
3+
44
describe('StringOffsets sanity checks', () => {
55
test('basic ASCII text', () => {
66
const text = "hello\nworld";

0 commit comments

Comments
 (0)