Skip to content

Commit

Permalink
chore: fix wasm build failed (rolldown#303)
Browse files Browse the repository at this point in the history
  • Loading branch information
hyf0 committed Nov 17, 2023
1 parent e49e4d5 commit 92914f8
Show file tree
Hide file tree
Showing 10 changed files with 48 additions and 37 deletions.
31 changes: 31 additions & 0 deletions crates/rolldown_binding_wasm/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
{
"name": "@rolldown/wasm-binding",
"version": "0.1.0",
"license": "MIT",
"repository": {
"type": "git",
"url": "https://github.com/rolldown-rs/rolldown"
},
"scripts": {
"build": "npm-run-all -s build:wasm clean-wasm-build",
"build:release": "npm-run-all -s build:wasm:release clean-wasm-build",
"build:wasm": "wasm-pack build --dev --target web -d ./dist",
"build:wasm:release": "wasm-pack build --release --target web -d ./dist",
"clean-wasm-build": "rm ./dist/.gitignore"
},
"files": [
"./dist/rolldown_wasm_binding_bg.wasm.d.ts",
"./dist/rolldown_wasm_binding_bg.wasm",
"./dist/rolldown_wasm_binding.js",
"./dist/rolldown_wasm_binding.d.ts"
],
"module": "./dist/rolldown_wasm_binding.js",
"types": "./dist/rolldown_wasm_binding.d.ts",
"homepage": "https://github.com/rolldown-rs/rolldown",
"sideEffects": [
"./snippets/*"
],
"devDependencies": {
"npm-run-all": "^4.1.5"
}
}
8 changes: 1 addition & 7 deletions justfile
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ _default:
just --list -u

init:
cargo binstall rusty-hook taplo-cli cargo-insta -y
cargo binstall rusty-hook taplo-cli cargo-insta wasm-pack -y
yarn install
git submodule update

Expand Down Expand Up @@ -37,9 +37,3 @@ bench:
cargo bench -p bench

# build wasm of rolldown and move the output `pkg/` under `web` directory

# Use `just wasm-build release` for better performance but also it will cost more time.
wasm-build mode="dev":
cd crates/rolldown_binding_wasm && wasm-pack build --{{ mode }} --target web
-rm -r ./web/wasm
mv crates/rolldown_binding_wasm/pkg ./web/wasm
3 changes: 3 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
"private": true,
"workspaces": [
"crates/rolldown_binding",
"crates/rolldown_binding_wasm",
"packages/**",
"web/**"
],
Expand All @@ -15,6 +16,8 @@
"build": "yarn workspaces foreach --all --topological-dev run build",
"build:binding": "yarn workspace @rolldown/node-binding run build",
"build:binding:release": "yarn workspace @rolldown/node-binding run build:release",
"build:wasm": "yarn workspace @rolldown/wasm-binding run build",
"build:wasm:release": "yarn workspace @rolldown/wasm-binding run build:release",
"test": "yarn workspaces foreach --all --parallel run test",
"test:update-rollup": "yarn workspace rollup-tests run test:update",
"prettier": "prettier . '!**/*.{js||ts|json|md|yml|yaml}' -w",
Expand Down
2 changes: 1 addition & 1 deletion web/playground/index.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import init, { bundle, FileItem, AssetItem } from '../wasm'
import init, { bundle, FileItem, AssetItem } from '@rolldown/wasm-binding'
await init()
let res = bundle([new FileItem('/index.js', 'const a = 3')])
let normalizedRes = res.map((item) => {
Expand Down
1 change: 1 addition & 0 deletions web/playground/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@
"dependencies": {
"@codemirror/lang-javascript": "^6.2.1",
"@codemirror/theme-one-dark": "^6.1.2",
"@rolldown/wasm-binding": "workspace:*",
"codemirror": "^6.0.1",
"path-browserify": "^1.0.1",
"vue": "^3.3.8",
Expand Down
2 changes: 1 addition & 1 deletion web/playground/src/App.vue
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<script setup lang="ts">
import { ref, onMounted, Ref } from 'vue'
import ModuleBlock from './components/ModuleBlock.vue'
import init, { bundle } from '../../wasm'
import init, { bundle } from '@rolldown/wasm-binding'
import {
convertAssetListToModuleList,
normalizeModules,
Expand Down
2 changes: 1 addition & 1 deletion web/playground/src/utils/index.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import * as path from 'path-browserify'
import { AssetItem, FileItem } from '../../../wasm'
import { AssetItem, FileItem } from '@rolldown/wasm-binding'

export type ModuleInfo = {
title: string
Expand Down
1 change: 0 additions & 1 deletion web/wasm/.gitignore

This file was deleted.

20 changes: 0 additions & 20 deletions web/wasm/package.json

This file was deleted.

15 changes: 9 additions & 6 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -1496,6 +1496,14 @@ __metadata:
languageName: unknown
linkType: soft

"@rolldown/wasm-binding@workspace:*, @rolldown/wasm-binding@workspace:crates/rolldown_binding_wasm":
version: 0.0.0-use.local
resolution: "@rolldown/wasm-binding@workspace:crates/rolldown_binding_wasm"
dependencies:
npm-run-all: "npm:^4.1.5"
languageName: unknown
linkType: soft

"@rollup/plugin-alias@npm:^5.0.0":
version: 5.0.1
resolution: "@rollup/plugin-alias@npm:5.0.1"
Expand Down Expand Up @@ -9688,6 +9696,7 @@ __metadata:
dependencies:
"@codemirror/lang-javascript": "npm:^6.2.1"
"@codemirror/theme-one-dark": "npm:^6.1.2"
"@rolldown/wasm-binding": "workspace:*"
"@types/path-browserify": "npm:^1.0.2"
"@vitejs/plugin-vue": "npm:^4.4.1"
codemirror: "npm:^6.0.1"
Expand Down Expand Up @@ -9723,12 +9732,6 @@ __metadata:
languageName: unknown
linkType: soft

"rolldown_wasm_binding@workspace:web/wasm":
version: 0.0.0-use.local
resolution: "rolldown_wasm_binding@workspace:web/wasm"
languageName: unknown
linkType: soft

"rollup-plugin-dts@npm:^6.0.0":
version: 6.1.0
resolution: "rollup-plugin-dts@npm:6.1.0"
Expand Down

0 comments on commit 92914f8

Please sign in to comment.