Skip to content

Commit

Permalink
feat: Webassembly setup (#2353)
Browse files Browse the repository at this point in the history
* feat: Webassembly setup
  • Loading branch information
haakonflatval-cognite authored Aug 26, 2022
1 parent a400e08 commit 8795a53
Show file tree
Hide file tree
Showing 77 changed files with 690 additions and 31 deletions.
16 changes: 13 additions & 3 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,13 @@ jobs:
continue-on-error: false
run: yarn run lint

- name: Rust fmt
working-directory: viewer
continue-on-error: false
run: |
rustup component add rustfmt
cargo fmt --check
# Skip to save time - development version is enough
# - name: Build prod version
# working-directory: viewer
Expand Down Expand Up @@ -212,11 +219,14 @@ jobs:
ci-parser-worker:
name: Parser worker
runs-on: ubuntu-latest
defaults:
run:
working-directory: legacy-parser-worker
steps:
- uses: actions/checkout@v3
- uses: technote-space/get-diff-action@v6
with:
PREFIX_FILTER: parser-worker
PREFIX_FILTER: legacy-parser-worker/parser-worker

- name: Setup Rust
if: env.GIT_DIFF
Expand Down Expand Up @@ -272,12 +282,12 @@ jobs:

- name: Install NPM dependencies
if: env.GIT_DIFF
working-directory: parser-worker
working-directory: legacy-parser-worker/parser-worker
run: yarn

- name: Build parser-worker
if: env.GIT_DIFF
working-directory: parser-worker
working-directory: legacy-parser-worker/parser-worker
run: yarn build:prod

build-preview-documentation:
Expand Down
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
# Generated by Cargo
# will have compiled files and executables
target
**/wasm/pkg/

# These are backup files generated by rustfmt
**/*.rs.bk
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -136,7 +136,7 @@ npm unlink
```

In case when you need to change and test the latest changes in parser-worker
consult [parser-worker/README.md](parser-worker/README.md)
consult [legacy-parser-worker/parser-worker/README.md](legacy-parser-worker/parser-worker/README.md)

## Releasing Reveal

Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ You can either run the same command as in Windows, or install it faster through
### Build

```bash
cd ./parser-worker
cd ./legacy-parser-worker/parser-worker
yarn
yarn build
```
Expand All @@ -63,13 +63,13 @@ If you set the env variable correctly, during the build you should see this prin
> ⬡ <webpack-log>: { publicPath: 'https://static.server/parser-worker/' }
```

Now `parser-worker/dist/local` folder contains the built worker and wasm files.
Now `legacy-parser-worker/parser-worker/dist/local` folder contains the built worker and wasm files.
You can host them at your static server.

### Local development

If you want to test your own changes in worker or rust module locally,
all you need to do is to copy files from `parser-worker/dist/local` to some folder in examples.
all you need to do is to copy files from `legacy-parser-worker/parser-worker/dist/local` to some folder in examples.

You can simply use `yarn local-cdn` it does:

Expand All @@ -80,7 +80,7 @@ You can simply use `yarn local-cdn` it does:

You will also need to link `@cognite/reveal-parser-worker` to the local version in order to get proper type declarations:

* From `parser-worker/`: `yarn link`
* From `legacy-parser-worker/parser-worker/`: `yarn link`
* From `viewer/`: `yarn link @cognite/reveal-parser-worker`

Notice that it builds the viewer with the same
Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -24,9 +24,9 @@
"cdn-upload": "node uploadToCDN.js",
"clean": "rimraf -rf ./dist ./pkg",
"local-cdn:build": "cross-var cross-env PUBLIC_PATH=https://localhost:$npm_package_conf_port/$npm_package_conf_folder/ yarn run build ",
"local-cdn:copy": "cross-var rimraf -rf ../examples/public/$npm_package_conf_folder && cross-var cpy ./dist/local/* ../examples/public/$npm_package_conf_folder/",
"local-cdn:copy": "cross-var rimraf -rf ../../examples/public/$npm_package_conf_folder && cross-var cpy ./dist/local/* ../../examples/public/$npm_package_conf_folder/",
"local-cdn:viewer": "cd ../viewer && cross-var cross-env PUBLIC_PATH=https://localhost:$npm_package_conf_port/$npm_package_conf_folder/ yarn build",
"local-cdn:start": "cd ../examples && cross-var cross-env PORT=$npm_package_conf_port yarn start",
"local-cdn:start": "cd ../../examples && cross-var cross-env PORT=$npm_package_conf_port yarn start",
"local-cdn": "yarn local-cdn:build && yarn local-cdn:copy && yarn local-cdn:viewer && yarn local-cdn:start",
"test": "echo \"Error: no test specified\" && exit 1",
"prebump": "yarn version --no-git-tag-version && yarn",
Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
10 changes: 5 additions & 5 deletions renovate.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@
],
"packageRules": [
{
"matchPaths": ["parser-worker", "i3df", "f3df", "openctm"],
"groupName": "parser-worker",
"matchPaths": ["legacy-parser-worker"],
"groupName": "legacy-parser-worker",
"enabled": false
},
{
Expand All @@ -19,15 +19,15 @@
{
"matchUpdateTypes": ["major"],
"automerge": false
},
},
{
"matchPackagePrefixes": [""],
"addLabels": ["dependencies", "auto-update"],
"prConcurrentLimit": 5
},
{
"matchLanguages": ["rust"],
"enabled": false
"matchPaths": ["viewer"],
"extends": ["github>Turbo87/renovate-config//rust/updateToolchain"]
},
{
"matchUpdateTypes": ["minor", "patch", "pin", "digest"],
Expand Down
2 changes: 2 additions & 0 deletions viewer/.eslintignore
Original file line number Diff line number Diff line change
@@ -1 +1,3 @@
dist/*
wasm/target/*
wasm/pkg/*
231 changes: 231 additions & 0 deletions viewer/Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

12 changes: 12 additions & 0 deletions viewer/Cargo.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
[workspace]

members = [
"packages/*/wasm"
]


[profile.release]
# This makes the compiled code faster and smaller, but it makes compiling slower,
# so it's only enabled in release mode.
lto = true
opt-level = 3
Loading

0 comments on commit 8795a53

Please sign in to comment.