Skip to content

Commit 1d0b1e8

Browse files
committed
Work on Windows support for JS binding (failed), see #578
1 parent 05e9266 commit 1d0b1e8

File tree

4 files changed

+26
-4
lines changed

4 files changed

+26
-4
lines changed

bindings/js/Makefile

+3
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,9 @@
11
SHELL=/usr/bin/env bash
22
VERSION=`git describe --tags --abbrev=0 | cut -b 2-`
33

4+
# needed explicitly for Windows
5+
export CGO_ENABLED=1
6+
47
# node-gyp will run c++ with -mmacosx-version-min=10.13, set golang to match this
58
ifeq ($(shell uname -s),Darwin)
69
export CGO_CFLAGS += -mmacosx-version-min=10.13

bindings/js/README.md

+19-2
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,24 @@
11
JavaScript bindings for the Go minifiers for web formats `minify`, see [github.com/tdewolff/minify](https://github.com/tdewolff/minify).
22

3-
## Requisites
4-
Make sure to have [Go](https://go.dev/doc/install) installed.
3+
## Installation on Windows
4+
THIS DOES NOT WORK UNFORTUNATELY
5+
6+
- Install [NPM](https://nodejs.org/en/download)
7+
- Install [Python](https://www.python.org/downloads/) (optional?)
8+
- Open Windows Command Prompt and run:
9+
- `$ npm install @tdewolff/minify`
10+
11+
### Build from source
12+
- Install [Git](https://git-scm.com/)
13+
- Install [NPM](https://nodejs.org/en/download)
14+
- Install [Python](https://www.python.org/downloads/)
15+
- Install [Build Tools for Visual Studio](https://visualstudio.microsoft.com/downloads/#build-tools-for-visual-studio-2022) under "Tools for Visual Studio". Make sure to also enable the "Desktop development with C++", see [NodeJS - On Windows](https://github.com/nodejs/node-gyp#on-windows)
16+
- Install [TDM-GCC](https://jmeubank.github.io/tdm-gcc/download/) and select the 64+32 bit version, this is only to provide the `mingw32-make` binary
17+
- Install [Go](https://go.dev/doc/install)
18+
- Open the Git Bash and run:
19+
- `$ git clone https://github.com/tdewolff/minify`
20+
- `$ cd minify/bindings/js`
21+
- `$ npm install`
522

623
## Usage
724
There are three functions available in JavaScript: configure the minifiers, minify a string, and minify a file. Below an example of their usage:

bindings/js/compile.bat

+1-1
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
make -C .. compile
1+
mingw32-make -C .. compile

bindings/js/minify.c

+3-1
Original file line numberDiff line numberDiff line change
@@ -278,4 +278,6 @@ napi_value init(napi_env env, napi_value exports) {
278278
return exports;
279279
}
280280

281-
NAPI_MODULE(NODE_GYP_MODULE_NAME, init)
281+
NAPI_MODULE_INIT() {
282+
return init(env, exports);
283+
}

0 commit comments

Comments
 (0)