#!/usr/bin/make -f
# -*- makefile -*-

export LC_ALL=C.UTF-8

%:
	dh $@

# Upstream builds with babel and webpack; this build uses babel and rollup
# (webpack is not packaged).  dist/dist/standalone/ is where the published
# upstream package keeps the UMD bundle, and consumers link to that path.
execute_after_dh_auto_build:
	babeljs src --out-dir dist
	cd section-iterator && babeljs index.js --out-file dist/index.js
	cd react-themeable && babeljs src --out-dir dist
	rollup -c debian/rollup.config.cjs

execute_before_dh_install:
	install -D -m 644 dist/dist/standalone/autosuggest.js \
	 debian/tmp/usr/share/javascript/react-autosuggest/autosuggest.js
	install -D -m 644 dist/dist/standalone/autosuggest.min.js \
	 debian/tmp/usr/share/javascript/react-autosuggest/autosuggest.min.js

# The blanket nodejs:Provides makes dpkg drop the component dependencies.
execute_before_dh_gencontrol:
	sed -i '/^nodejs:Provides=/d' debian/*.substvars
