Skip to content

Commit

Permalink
Add exports file to dist
Browse files Browse the repository at this point in the history
  • Loading branch information
MulverineX committed Dec 1, 2023
1 parent 2ab82a9 commit 5ed8124
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 2 deletions.
10 changes: 9 additions & 1 deletion build-sandstone.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { readdirSync } from "fs";
import { mkdirSync, readdirSync, writeFileSync } from "fs";
import { resolve } from "path";
import { build } from "esbuild";
const shims = readdirSync("./web-shim");
Expand Down Expand Up @@ -58,6 +58,14 @@ export const sandstoneBuild = build({
"adm-zip",
"prismarine-nbt",
],
metafile: true,
format: "esm",
minify: true,
}).then((data) => {
const exports = Object.values(data.metafile.outputs)[0].exports;
mkdirSync('./dist', { recursive: true })
writeFileSync(
"./dist/exports.js",
"export const exports = " + JSON.stringify(exports) + ";"
);
});
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@sandstone-mc/playground",
"version": "0.1.2",
"version": "0.1.3",
"type": "module",
"exports": "./dist/main.js",
"module": "dist/main.js",
Expand Down
1 change: 1 addition & 0 deletions vite.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ export default sandstoneBuild.then(() =>
defineConfig({
plugins: [nodePolyfills()],
build: {
emptyOutDir: false,
lib: {
entry: "src/main.ts",
fileName: "main",
Expand Down

0 comments on commit 5ed8124

Please sign in to comment.