Skip to content
Open
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
5 changes: 1 addition & 4 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,5 @@ test-data/mainnet
test-data/keys
.projectile
/dist/*
!/dist/esbuild/
/dist/esbuild/*
!/dist/esbuild/index.html
!/dist/esbuild/wrapper.js
output.js
/*.tgz
67 changes: 12 additions & 55 deletions Makefile
Original file line number Diff line number Diff line change
@@ -1,79 +1,36 @@
SHELL := bash
.ONESHELL:
.PHONY: esbuild-bundle esbuild-serve webpack-bundle webpack-serve check-format format query-testnet-tip clean check-explicit-exports spago-build create-bundle-entrypoint create-html-entrypoint delete-bundle-entrypoint generate-purs-scripts
.PHONY: build bundle test format check-format clean generate-purs-scripts
.SHELLFLAGS := -eu -o pipefail -c

ps-sources := $(shell fd --no-ignore-parent -epurs)
nix-sources := $(shell fd --no-ignore-parent -enix --exclude='spago*')
js-sources := $(shell fd --no-ignore-parent -ejs -ecjs)

### Bundler setup

# The entry point function in the main PureScript module
ps-entrypoint-function := main
# Whether to bundle for the browser
browser-runtime := 1 # Use "1" for true and "" for false

# Bundler for the library

# The main Purescript module
ps-entrypoint := Dao.Web.Api
# Bundle command
ps-bundle = webpack -c webpack.config.ps.cjs --mode=production

preview-node-ipc = $(shell docker volume inspect store_node-preview-ipc | jq -r '.[0].Mountpoint')
preprod-node-ipc = $(shell docker volume inspect store_node-preprod-ipc | jq -r '.[0].Mountpoint')
serve-port := 4008

spago-build:
@spago build

create-bundle-entrypoint:
@mkdir -p dist/
@echo 'import("../output/${ps-entrypoint}/index.js").then(m => m.${ps-entrypoint-function}());' > ./dist/entrypoint.js

create-html-entrypoint:
@mkdir -p dist/
@cat << EOF > dist/index.html
<!DOCTYPE html>
<html>
<body><script type="module" src="./index.js"></script></body>
</html>
EOF

delete-bundle-entrypoint:
@rm -f ./dist/entrypoint.js

esbuild-bundle: spago-build create-bundle-entrypoint
BROWSER_RUNTIME=${browser-runtime} node esbuild/bundle.js ./dist/entrypoint.js dist/index.js
@make delete-bundle-entrypoint

esbuild-serve: spago-build create-bundle-entrypoint create-html-entrypoint
purs-args := "--stash --censor-lib --censor-codes=ImplicitImport,ImplicitQualifiedImport,ImplicitQualifiedImportReExport,UserDefinedWarning,UnusedName,ShadowedName,MissingTypeDeclaration"

BROWSER_RUNTIME=1 node esbuild/serve.js ./dist/entrypoint.js dist/index.js dist/ ${serve-port}
build:
spago build --purs-args ${purs-args}

webpack-bundle: spago-build create-bundle-entrypoint
BROWSER_RUNTIME=${browser-runtime} webpack --mode=production \
-o dist/ --env entry=./dist/entrypoint.js
@make delete-bundle-entrypoint
bundle: build
BROWSER_RUNTIME=${browser-runtime} node esbuild/bundle.js output/${ps-entrypoint}/index.js dist/index.js

webpack-serve: spago-build create-bundle-entrypoint create-html-entrypoint
BROWSER_RUNTIME=1 webpack-dev-server --progress \
--port ${serve-port} \
-o dist/ --env entry=./dist/entrypoint.js
test:
spago run --main Test.Localnet

run-build:
@${ps-bundle} && BROWSER_RUNTIME=1 webpack -c webpack.config.lib.cjs --mode=production
format:
@purs-tidy format-in-place ${ps-sources}
prettier -w ${js-sources}

check-format:
@purs-tidy check ${ps-sources}
@prettier --loglevel warn -c ${js-sources}
@eslint --quiet ${js-sources} --parser-options 'sourceType: module'

format:
@purs-tidy format-in-place ${ps-sources}
prettier -w ${js-sources}

clean:
@ rm -r .psc-ide-port || true
@ rm -rf .psci_modules || true
Expand All @@ -98,4 +55,4 @@ generate-purs-scripts:
echo "$$var_name = \"$$value\"" >> $$output_file; \
done; \
done
@echo "All PureScript scripts generated."
@echo "All PureScript scripts generated."
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,11 @@ First, enter the Nix shell by running `nix develop`.

## Testing

To execute the Plutip tests, run `npm run test`.
To execute the `cardano-testnet`-based integration tests, run `make test`.

## Building

The project can be built by running `spago build`.
The project can be built by running `make build`.

## Updating On-Chain Scripts

Expand Down
2 changes: 1 addition & 1 deletion esbuild/config.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ export const buildOptions = ({ entryPoint, outfile }) => {
},
plugins: [
wasmLoader({
mode: "deferred",
mode: "embedded", // deferred?
}),
],
bundle: true,
Expand Down
72 changes: 0 additions & 72 deletions esbuild/serve.js

This file was deleted.

Loading