Skip to content

Commit

Permalink
feat: support node
Browse files Browse the repository at this point in the history
  • Loading branch information
gz65555 committed Mar 19, 2024
1 parent 338244f commit 94fbd5b
Show file tree
Hide file tree
Showing 4 changed files with 132 additions and 13 deletions.
11 changes: 7 additions & 4 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,15 +6,15 @@
"packageManager": "pnpm@8.6.2",
"exports": {
"node": {
"import": "./dist/node.esm.js",
"import": "./dist/node/index.js",
"types": "./types/node/index.d.ts"
},
"default": {
"import": "./dist/web.esm.js",
"import": "./dist/web/index.js",
"types": "./types/web/index.d.ts"
}
},
"types": "types/index.d.ts",
"types": "types/web/index.d.ts",
"repository": "github:gz65555/ktx2-encoder",
"author": {
"name": "Hu Song",
Expand All @@ -24,7 +24,7 @@
"scripts": {
"dev": "vite --host",
"docs": "typedoc src/index.ts --plugin typedoc-plugin-markdown --out ./docs",
"build": "tsc && rollup -c",
"build": "tsc -p tsconfig.json && cp -R src/node/basis dist/node",
"test": "npm run test:node && npm run test:web",
"test:node": "vitest ./test/node.test.ts",
"test:web": "vitest --browser.name=chrome ./test/web.test.ts",
Expand All @@ -46,6 +46,7 @@
"devDependencies": {
"@ant-design/icons": "^5.2.5",
"@galacean/engine": "^1.1.0-beta.50",
"@rollup/plugin-alias": "^5.1.0",
"@rollup/plugin-node-resolve": "^15.0.1",
"@swc/core": "^1.3.35",
"@types/node": "^20.11.10",
Expand All @@ -63,6 +64,8 @@
"rollup": "^3",
"rollup-plugin-swc3": "^0.11.0",
"sharp": "^0.33.2",
"tsc-alias": "^1.8.8",
"tsconfig-paths": "^4.2.0",
"typedoc": "^0.24.8",
"typedoc-plugin-markdown": "^3.15.3",
"typescript": "^5",
Expand Down
109 changes: 109 additions & 0 deletions pnpm-lock.yaml

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

18 changes: 12 additions & 6 deletions rollup.config.mjs
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
import resolve from "@rollup/plugin-node-resolve";
import { swc, defineRollupSwcOption, minify } from "rollup-plugin-swc3";
import alias from "@rollup/plugin-alias";

const plugins = [
resolve({ extensions: [".ts"] }),
resolve({ extensions: [".ts"], browser: false }),
swc(
defineRollupSwcOption({
include: /\.[mc]?[jt]sx?$/,
Expand All @@ -14,10 +15,13 @@ const plugins = [
},
sourceMaps: true
})
),
minify({
module: true
})
)
// alias({
// entries: [{ find: "@basis/basis_encoder.js", replacement: "../libs/basis_encoder.js" }]
// })
// minify({
// module: true
// })
];

export default [
Expand All @@ -34,10 +38,12 @@ export default [
{
input: "./src/node/index.ts",
plugins,
external: ["@basis/basis_encoder.js"],
output: [
{
file: "dist/node.esm.js",
format: "es"
format: "es",
inlineDynamicImports: true
}
]
}
Expand Down
7 changes: 4 additions & 3 deletions tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@

/* Bundler mode */
"moduleResolution": "bundler",
"allowImportingTsExtensions": true,
"allowImportingTsExtensions": false,
"resolveJsonModule": true,
"isolatedModules": true,
"jsx": "react-jsx",
Expand All @@ -19,9 +19,10 @@
"noUnusedParameters": false,
"typeRoots": ["./node_modules/@webgpu/types", "./node_modules/@types"],
"noFallthroughCasesInSwitch": true,
"emitDeclarationOnly": true,
"emitDeclarationOnly": false,
"declaration": true,
"outDir": "types"
"declarationDir": "types",
"outDir": "dist"
},
"include": ["src"],
"references": [{ "path": "./tsconfig.node.json" }]
Expand Down

0 comments on commit 94fbd5b

Please sign in to comment.