Skip to content

Commit 0d3dbff

Browse files
committed
Small fixes for JS packaging and copying
1 parent f2ef3f1 commit 0d3dbff

File tree

6 files changed

+12
-24
lines changed

6 files changed

+12
-24
lines changed

cppjswasm/js/build.mjs.jinja

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,7 @@
11
import { bundle } from "./tools/bundle.mjs";
22
import { bundle_css } from "./tools/css.mjs";
33
import { node_modules_external } from "./tools/externals.mjs";
4-
import { getarg } from "./tools/getarg.mjs";
54

6-
import { transform } from "lightningcss";
75
import fs from "fs";
86
import cpy from "cpy";
97

@@ -24,8 +22,6 @@ async function build() {
2422
await bundle_css();
2523

2624
// Copy HTML
27-
fs.mkdirSync("dist/html", { recursive: true });
28-
cpy("src/html/*", "dist/html");
2925
cpy("src/html/*", "dist/");
3026

3127
// Copy images
@@ -34,9 +30,9 @@ async function build() {
3430

3531
await Promise.all(BUNDLES.map(bundle)).catch(() => process.exit(1));
3632

37-
// Copy from dist to python
33+
// Copy servable assets to python extension (exclude esm/)
3834
fs.mkdirSync("../{{ module }}/extension", { recursive: true });
39-
cpy("dist/**/*", "../{{ module }}/extension");
35+
cpy("dist/**/*", "../{{ module }}/extension", { filter: (file) => !file.relativePath.startsWith("esm") });
4036
}
4137

4238
build();

cppjswasm/js/tools/css.mjs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -35,8 +35,8 @@ const bundle_one = async (file, resolver) => {
3535
resolver: resolver || DEFAULT_RESOLVER,
3636
});
3737
const outName = path.basename(file);
38-
fs.mkdirSync("./dist", { recursive: true });
39-
fs.writeFileSync(path.join("./dist", outName), code);
38+
fs.mkdirSync("./dist/css", { recursive: true });
39+
fs.writeFileSync(path.join("./dist/css", outName), code);
4040
};
4141

4242
export const bundle_css = async (root = "src/css/index.css", resolver = null) => {

js/js/build.mjs.jinja

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,7 @@
11
import { bundle } from "./tools/bundle.mjs";
22
import { bundle_css } from "./tools/css.mjs";
33
import { node_modules_external } from "./tools/externals.mjs";
4-
import { getarg } from "./tools/getarg.mjs";
54

6-
import { transform } from "lightningcss";
75
import fs from "fs";
86
import cpy from "cpy";
97

@@ -24,8 +22,6 @@ async function build() {
2422
await bundle_css();
2523

2624
// Copy HTML
27-
fs.mkdirSync("dist/html", { recursive: true });
28-
cpy("src/html/*", "dist/html");
2925
cpy("src/html/*", "dist/");
3026

3127
// Copy images
@@ -34,9 +30,9 @@ async function build() {
3430

3531
await Promise.all(BUNDLES.map(bundle)).catch(() => process.exit(1));
3632

37-
// Copy from dist to python
33+
// Copy servable assets to python extension (exclude esm/)
3834
fs.mkdirSync("../{{ module }}/extension", { recursive: true });
39-
cpy("dist/**/*", "../{{ module }}/extension");
35+
cpy("dist/**/*", "../{{ module }}/extension", { filter: (file) => !file.relativePath.startsWith("esm") });
4036
}
4137

4238
build();

js/js/tools/css.mjs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -35,8 +35,8 @@ const bundle_one = async (file, resolver) => {
3535
resolver: resolver || DEFAULT_RESOLVER,
3636
});
3737
const outName = path.basename(file);
38-
fs.mkdirSync("./dist", { recursive: true });
39-
fs.writeFileSync(path.join("./dist", outName), code);
38+
fs.mkdirSync("./dist/css", { recursive: true });
39+
fs.writeFileSync(path.join("./dist/css", outName), code);
4040
};
4141

4242
export const bundle_css = async (root = "src/css/index.css", resolver = null) => {

rustjswasm/js/build.mjs.jinja

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,7 @@
11
import { bundle } from "./tools/bundle.mjs";
22
import { bundle_css } from "./tools/css.mjs";
33
import { node_modules_external } from "./tools/externals.mjs";
4-
import { getarg } from "./tools/getarg.mjs";
54

6-
import { transform } from "lightningcss";
75
import fs from "fs";
86
import cpy from "cpy";
97

@@ -24,8 +22,6 @@ async function build() {
2422
await bundle_css();
2523

2624
// Copy HTML
27-
fs.mkdirSync("dist/html", { recursive: true });
28-
cpy("src/html/*", "dist/html");
2925
cpy("src/html/*", "dist/");
3026

3127
// Copy images
@@ -34,9 +30,9 @@ async function build() {
3430

3531
await Promise.all(BUNDLES.map(bundle)).catch(() => process.exit(1));
3632

37-
// Copy from dist to python
33+
// Copy servable assets to python extension (exclude esm/)
3834
fs.mkdirSync("../{{ module }}/extension", { recursive: true });
39-
cpy("dist/**/*", "../{{ module }}/extension");
35+
cpy("dist/**/*", "../{{ module }}/extension", { filter: (file) => !file.relativePath.startsWith("esm") });
4036
}
4137

4238
build();

rustjswasm/js/tools/css.mjs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -35,8 +35,8 @@ const bundle_one = async (file, resolver) => {
3535
resolver: resolver || DEFAULT_RESOLVER,
3636
});
3737
const outName = path.basename(file);
38-
fs.mkdirSync("./dist", { recursive: true });
39-
fs.writeFileSync(path.join("./dist", outName), code);
38+
fs.mkdirSync("./dist/css", { recursive: true });
39+
fs.writeFileSync(path.join("./dist/css", outName), code);
4040
};
4141

4242
export const bundle_css = async (root = "src/css/index.css", resolver = null) => {

0 commit comments

Comments
 (0)