Skip to content

Commit 92ccbd0

Browse files
committed
publishing
1 parent 4ba2b79 commit 92ccbd0

File tree

3 files changed

+40
-12
lines changed

3 files changed

+40
-12
lines changed

.github/workflows/build.yaml

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,10 @@
1-
name: Build with Emscripten
1+
name: Build with Emscripten and publish to npmjs
22

3-
on: [push, pull_request]
3+
on:
4+
workflow_dispatch:
5+
6+
release:
7+
types: [published]
48

59
jobs:
610
build:
@@ -31,4 +35,10 @@ jobs:
3135
source ./emsdk/emsdk_env.sh
3236
npm install
3337
npm run build
38+
cp ./test/llama-3.1-tokenizer.model ./dist/llama-3.1-tokenizer.model
39+
40+
- name: Publish to npmjs registry
41+
run: |
42+
npm config set "//registry.npmjs.org/:_authToken=${{ secrets.NPM_TOKEN }}"
43+
npm publish
3444

package.json

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
{
2-
"name": "sentencepiece-js",
2+
"name": "@sctg/sentencepiece-js",
33
"version": "1.2.0",
44
"description": "Sentencepiece tokenization for natural language processing, JS version.",
55
"main": "dist/index.js",
@@ -14,7 +14,9 @@
1414
"develop": "web-dev-server --node-resolve --watch --open"
1515
},
1616
"files": [
17-
"./dist/index.js"
17+
"./dist/index.js",
18+
"./dist/index.d.ts",
19+
"./dist/llama-3.1-tokenizer.model"
1820
],
1921
"repository": {
2022
"type": "git",
@@ -41,10 +43,15 @@
4143
"@web/dev-server": "^0.4.6",
4244
"@web/test-runner": "^0.19.0",
4345
"rollup": "^4.24.0",
46+
"rollup-plugin-dts": "^6.1.1",
4447
"tslib": "^2.7.0",
4548
"typescript": "^5.6.2"
4649
},
4750
"dependencies": {
4851
"app-root-path": "^3.1.0"
52+
},
53+
"publishConfig": {
54+
"access": "public",
55+
"tag": "latest"
4956
}
50-
}
57+
}

rollup.config.mjs

Lines changed: 18 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -2,12 +2,23 @@ import { nodeResolve } from '@rollup/plugin-node-resolve';
22
import commonjs from '@rollup/plugin-commonjs';
33
import { wasm } from '@rollup/plugin-wasm';
44
import typescript from '@rollup/plugin-typescript';
5+
import dts from 'rollup-plugin-dts';
56

6-
export default {
7-
input: 'src/index.ts',
8-
output: {
9-
dir: 'dist',
10-
format: 'cjs'
7+
export default [
8+
{
9+
input: 'src/index.ts',
10+
output: {
11+
dir: 'dist',
12+
format: 'cjs'
13+
},
14+
plugins: [nodeResolve({ browser: true }), commonjs(), wasm(), typescript({ target: "es5", downlevelIteration: true })]
1115
},
12-
plugins: [nodeResolve({ browser: true }), commonjs(), wasm(), typescript({ target: "es5", downlevelIteration: true })]
13-
};
16+
{
17+
input: 'src/index.ts',
18+
output: {
19+
file: 'dist/index.d.ts',
20+
format: 'es'
21+
},
22+
plugins: [dts()]
23+
}
24+
];

0 commit comments

Comments
 (0)