POC of using Haxe and Neutralino
Read more about it in the README_HAXE.MD!
We begin with the installing the Typescript starter project for Neutralinojs
# install neutralino cli
$ npm i -g @neutralinojs/neu
# create a typescript neutrolin app
$ neu create myapp --template ts
$ cd myapp
# build project
$ neu build
Install neu-cli
$ npm i -g @neutralinojs/neu
Create Neutralino app with Typescript template
$ neu create myapp --template ts
$ cd myapp
Bundle source files
$ neu build
Learn more about neu-cli from docs
The haxe part:
# install dts2hx via npm
npm install dts2hx --save-dev
# copy typescript file to correct folder
mkdir -p node_modules/@types/neutralino
cp -i src/index.d.ts node_modules/@types/neutralino/index.d.ts
# convert typescript files to hx
npx dts2hx neutralino/index.d.ts
Install dts2hx via npm, we will us that to generate externs for Haxe
# install dts2hx via npm
npm install dts2hx --save-dev
Copy file to correct folder to convert to externs
Currently dts2hx expects the ts files to be in a repo in node_modules,
to get that working we just copy the files to that folder.
# copy typescript file to correct folder
mkdir -p node_modules/@types/neutralino
cp -i src/index.d.ts node_modules/@types/neutralino/index.d.ts
And convert the typescript files to Haxe externs
# convert typescript files to hx
npx dts2hx neutralino/index.d.ts
The Haxe externs
you will end up with a tree structure like this
.
├── LICENSE
├── README.md
├── app
│ ├── assets
│ │ ├── app.css
│ │ ├── app.js
│ │ └── neutralino.js
│ ├── index.html
│ ├── settings-browser.json
│ ├── settings-cloud.json
│ └── settings.json
├── externs
│ ├── global
│ │ ├── IndexGlobal.hx
│ │ ├── Neutralino.hx
│ │ └── neutralino
│ │ ├── App.hx
│ │ ├── AppMode.hx
│ │ ├── Computer.hx
│ │ ├── Debug.hx
│ │ ├── DirectoryData.hx
│ │ ├── FileData.hx
│ │ ├── Filesystem.hx
│ │ ├── InitOptions.hx
│ │ ├── LogSuccessData.hx
│ │ ├── LogType.hx
│ │ ├── Os.hx
│ │ ├── RamData.hx
│ │ ├── Settings.hx
│ │ ├── SettingsData.hx
│ │ ├── StdoutData.hx
│ │ ├── Storage.hx
│ │ ├── StoragePutData.hx
│ │ ├── SuccessData.hx
│ │ └── ValueData.hx
│ └── ts
│ └── Tuple1.hx
├── hx-neutralino-linux
├── hx-neutralino-mac
├── hx-neutralino-win.exe
├── neutralino.png
├── neutralinojs.log
├── package-lock.json
├── package.json
├── src
│ ├── app-core
│ │ └── lib.ts
│ ├── app.ts
│ ├── index.d.ts
│ ├── mycss.css
│ └── mycss2.css
├── storage
├── tsconfig.json
└── webpack.config.js
- create folder
hx - create
Main.hxand copy thisMain.hxcontent andappcore/Applib.hx - create
build.hxml
For now this will bypass the whole webpacker setup
--class-path hx
--class-path externs
--main Main
--js app/assets/app.js
--dce full
-D js-es=6
install haxe-loader (https://github.com/jasononeil/webpack-haxe-loader)
haxelib install haxe-loader
npm install --save-dev css-loader file-loader haxe-loader
and uninstall
npm uninstall typescript ts-loader
example
source: https://github.com/elsassph/webpack-haxe-example/blob/vanilla/package.json
- remove ts folder structure
- remove ts webpacker (use js version)
- use https://github.com/jasononeil/webpack-haxe-loader for Haxe webpack
Leave a Reply