-
Notifications
You must be signed in to change notification settings - Fork 73
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(wasm): Support more targets (#848)
- Loading branch information
1 parent
c6e8619
commit 049bb7c
Showing
10 changed files
with
98 additions
and
16 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1,5 @@ | ||
stylua.bundler/ | ||
stylua.node/ | ||
stylua.web/ | ||
stylua_lib.cjs | ||
LICENSE.md | ||
README.md | ||
*.tgz |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,10 @@ | ||
# TODO: Ensure that version is up to date | ||
cp README.md wasm/ | ||
cp LICENSE.md wasm/ | ||
npx [email protected] build --target nodejs --out-dir wasm/stylua.node -- --features lua52,lua53,lua54,luau | ||
npx [email protected] build --target bundler --out-dir wasm/stylua.bundler -- --features lua52,lua53,lua54,luau | ||
npx [email protected] build --target web --out-dir wasm/stylua.web -- --features lua52,lua53,lua54,luau | ||
|
||
# workaround for bundler usage | ||
echo "export { getImports as __getImports, finalizeInit as __finalizeInit }" >> wasm/stylua.web/stylua_lib.js | ||
|
||
# bundle for node CommonJS | ||
npx [email protected] wasm/src/stylua_lib_node.cjs --file wasm/stylua_lib.cjs --format cjs |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
export * from "../stylua.web/stylua_lib.js"; | ||
import { initSync } from "../stylua.web/stylua_lib.js"; | ||
|
||
const path = require("path").join(__dirname, "stylua.web/stylua_lib_bg.wasm"); | ||
const bytes = require("fs").readFileSync(path); | ||
|
||
initSync(bytes); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
export type * from "./stylua.web/stylua_lib"; | ||
export declare const initSync: never; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
export type * from "./stylua.web/stylua_lib"; | ||
export declare const initSync: never; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
import fs from "node:fs"; | ||
import { initSync } from "./stylua.web/stylua_lib.js"; | ||
|
||
const wasm = new URL("./stylua.web/stylua_lib_bg.wasm", import.meta.url); | ||
initSync(fs.readFileSync(wasm)); | ||
|
||
export * from "./stylua.web/stylua_lib.js"; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
export type * from "./stylua.web/stylua_lib"; | ||
export declare const initSync: never; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
import * as wasm from "./stylua.web/stylua_lib_bg.wasm"; | ||
|
||
import { __finalizeInit } from "./stylua.web/stylua_lib.js"; | ||
|
||
__finalizeInit({ exports: wasm }); | ||
|
||
export * from "./stylua.web/stylua_lib.js"; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
module.exports = require("./stylua.web/stylua_lib.js").__getImports().wbg; |