Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .copier-answers.yaml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# Changes here will be overwritten by Copier
_commit: cb37079
_commit: d814faa
_src_path: https://github.com/python-project-templates/base.git
add_docs: true
add_extension: js
Expand Down
22 changes: 16 additions & 6 deletions js/build.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -18,23 +18,33 @@ const BUNDLES = [
];

async function build() {
fs.rmSync("dist", { recursive: true, force: true });
fs.rmSync("../python_template_js/extension", {
recursive: true,
force: true,
});

// Bundle css
await bundle_css();

// Copy HTML
cpy("src/html/*", "dist/");
await cpy("src/html/*", "dist/");

// Copy images
fs.mkdirSync("dist/img", { recursive: true });
cpy("src/img/*", "dist/img");
if (fs.existsSync("src/img")) {
fs.mkdirSync("dist/img", { recursive: true });
await cpy("src/img/*", "dist/img");
}

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

// Copy servable assets to python extension (exclude esm/)
fs.mkdirSync("../python_template_js/extension", { recursive: true });
cpy("dist/**/*", "../python_template_js/extension", {
filter: (file) => !file.relativePath.startsWith("esm"),
await cpy("dist/**/*", "../python_template_js/extension", {
filter: (file) =>
!file.relativePath.startsWith("esm/") &&
!file.relativePath.startsWith("dist/esm/"),
});
}

build();
await build();
7 changes: 4 additions & 3 deletions js/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -18,16 +18,17 @@
"./package.json": "./package.json"
},
"files": [
"dist/**/*",
"index.d.ts"
"dist/**/*"
],
"types": "./dist/esm/index.d.ts",
"publishConfig": {
"access": "public"
},
"scripts": {
"build:debug": "node build.mjs --debug",
"build": "node build.mjs",
"build:prod": "node build.mjs",
"build:types": "tsc",
"build": "npm-run-all build:prod build:types",
"clean": "rm -rf dist playwright-report ../python_template_js/extension",
"dev": "npm-run-all -p start watch",
"lint": "oxlint . && oxfmt --check \"src/**/*.{js,ts,jsx,tsx,css}\" \"tests/**/*.{js,ts,jsx,tsx}\" \"*.mjs\" \"*.json\"",
Expand Down
4 changes: 2 additions & 2 deletions js/tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -14,11 +14,11 @@
"noFallthroughCasesInSwitch": true,
"outDir": "./dist/esm",
"resolveJsonModule": true,
"rootDir": ".",
"rootDir": "./src/ts",
"skipLibCheck": true,
"strict": true,
"target": "ES2020",
"useDefineForClassFields": true
},
"include": ["./src/ts/*.ts", "./tests/*.ts"]
"include": ["./src/ts/*.ts"]
}