mirror of
https://github.com/Bismuth-Forge/bismuth.git
synced 2024-11-04 13:37:43 +03:00
feat!: compile as module
This breaks the script for now, but it works
This commit is contained in:
parent
d8fa0536e9
commit
f09d2c550a
10
bin/build.sh
10
bin/build.sh
@ -6,9 +6,15 @@ mkdir -p $npm_package_config_build_dir/contents/code
|
||||
mkdir -p $npm_package_config_build_dir/contents/config
|
||||
mkdir -p $npm_package_config_build_dir/contents/ui
|
||||
|
||||
# Compile source into the single script used by KWin
|
||||
# Compile source into the form usable from QML
|
||||
echo "Compiling typescript..."
|
||||
npx tsc --outFile $npm_package_config_build_dir/contents/code/script.js
|
||||
npx tsc --outDir $npm_package_config_build_dir/contents/code/
|
||||
|
||||
# Rename all js files to mjs, because TypeScript cannot do that (https://github.com/Microsoft/TypeScript/issues/18442)
|
||||
# We need to to that in order to use Javascripts modules from Qt
|
||||
find $npm_package_config_build_dir/contents/code/ -name "*.js" -exec bash -c 'mv "$1" "${1%.js}".mjs' - '{}' \;
|
||||
# Fix the import statements (replace .js to .mjs, or add .mjs extention)
|
||||
find $npm_package_config_build_dir/contents/code/ -name "*.mjs" -exec sed -i '/^import/s/\.js/.mjs/g' {} +
|
||||
|
||||
# Copy resources to the build directory with correct paths
|
||||
cp -v res/config.ui $npm_package_config_build_dir/contents/ui/config.ui
|
||||
|
@ -23,7 +23,7 @@ import org.kde.plasma.core 2.0 as PlasmaCore;
|
||||
import org.kde.plasma.components 2.0 as Plasma;
|
||||
import org.kde.kwin 2.0;
|
||||
import org.kde.taskmanager 0.1 as TaskManager
|
||||
import "../code/script.js" as K
|
||||
import "../code/index.mjs" as K
|
||||
|
||||
Item {
|
||||
id: scriptRoot
|
||||
@ -48,7 +48,8 @@ Item {
|
||||
}
|
||||
|
||||
Component.onCompleted: {
|
||||
console.log("BISMUTH: starting the script");
|
||||
(new K.KWinDriver()).main();
|
||||
console.log("BISMUTH2: starting the script");
|
||||
K.main();
|
||||
// (new K.KWinDriver()).main();
|
||||
}
|
||||
}
|
||||
|
7
src/index.ts
Normal file
7
src/index.ts
Normal file
@ -0,0 +1,7 @@
|
||||
import hello from "./mod.js"
|
||||
|
||||
export function main() {
|
||||
console.log("Hello from main script!")
|
||||
console.log("import mod.js")
|
||||
hello()
|
||||
}
|
3
src/mod.ts
Normal file
3
src/mod.ts
Normal file
@ -0,0 +1,3 @@
|
||||
export default function hello() {
|
||||
console.log("Hello from module!");
|
||||
}
|
@ -6,7 +6,8 @@
|
||||
"removeComments": true,
|
||||
"lib": ["es5"],
|
||||
"alwaysStrict": true,
|
||||
"strict": true
|
||||
"strict": true,
|
||||
"module": "ES6"
|
||||
},
|
||||
"typedocOptions": {
|
||||
"entryPoints": ["src"]
|
||||
|
Loading…
Reference in New Issue
Block a user