mirror of
https://github.com/compiler-explorer/compiler-explorer.git
synced 2026-12-01 02:31:20 -06:00
Makes the Compiler Explorer app, and all the tooling ESM compatible. Things that have been done: 1. The package.json has `type: module` now 2. All relative imports have a .js ending 3. All directory imports are now directory/index.js to comply with ESM standards 4. Dependency node-graceful is now imported into tree, because the package is broken under esm 5. Dependency p-queue has been bumped to 7.x with ESM support 6. Dependency profanities has been bumped to 3.x with ESM support 7. Webpack config is now both ESM and CommonJS compatible 8. Non-ESM compatible imports have been rewritten 9. ESLint configuration has been tweaked to not fail on .js imports 10. Mocha is now hacked together and ran with ts-node-esm 11. Webpack is now hacked together and ran with ts-node-esm 12. Webpack config is now ESM compatible, so that it can be used in the dev server 13. Cypress code still runs commonjs, and has been excluded from the tsconfig 14. All sinon mock tests have been commented out, because sinon module mocks do not work with ESModules (because ESModules are immutable) A lot of tests are now giving warnings/errors to stdout, yet still pass. Docenizer codegenerator scripts have been updated, but I did not re-run them, and instead just changed their code. --------- Co-authored-by: Matt Godbolt <matt@godbolt.org>
108 lines
4.0 KiB
Makefile
108 lines
4.0 KiB
Makefile
default: run
|
|
|
|
help: # with thanks to Ben Rady
|
|
@grep -E '^[0-9a-zA-Z_-]+:.*?## .*$$' $(MAKEFILE_LIST) | sort | awk 'BEGIN {FS = ":.*?## "}; {printf "\033[36m%-20s\033[0m %s\n", $$1, $$2}'
|
|
|
|
# If you see "node-not-found" then you need to depend on node-installed.
|
|
NODE:=node-not-found
|
|
NPM:=npm-not-found
|
|
NODE_MODULES:=./node_modules/.npm-updated
|
|
|
|
# These 'find' scripts cache their results in a dotfile.
|
|
# Doing it this way instead of NODE:=$(shell etc/script/find-node) means
|
|
# if they fail, they stop the make process. As best I can tell there's no
|
|
# way to get make to fail if a sub-shell command fails.
|
|
.node-bin: etc/scripts/find-node
|
|
@etc/scripts/find-node .node-bin
|
|
|
|
# All targets that need node must depend on this to ensure the NODE variable
|
|
# is appropriately set, and that PATH is updated.
|
|
.PHONY: node-installed
|
|
node-installed: .node-bin
|
|
@$(eval NODE:=$(shell cat .node-bin))
|
|
@$(eval NPM:=$(shell dirname $(shell cat .node-bin))/npm)
|
|
@$(eval PATH=$(shell dirname $(realpath $(NODE))):$(PATH))
|
|
|
|
.PHONY: info
|
|
info: node-installed ## print out some useful variables
|
|
@echo Using node from $(NODE)
|
|
@echo Using npm from $(NPM)
|
|
@echo PATH is $(PATH)
|
|
|
|
.PHONY: prereqs
|
|
prereqs: $(NODE_MODULES)
|
|
|
|
$(NODE_MODULES): package.json | node-installed
|
|
$(NPM) install $(NPM_FLAGS)
|
|
@rm -rf node_modules/.cache/esm/*
|
|
@touch $@
|
|
|
|
.PHONY: lint
|
|
lint: $(NODE_MODULES) ## Checks if the source currently matches code conventions
|
|
$(NPM) run ts-check
|
|
$(NPM) run lint-check
|
|
|
|
.PHONY: lint-fix
|
|
lint-fix: $(NODE_MODULES) ## Checks if everything matches code conventions & fixes those which are trivial to do so
|
|
$(NPM) run lint
|
|
|
|
.PHONY: ci-lint
|
|
ci-lint: $(NODE_MODULES)
|
|
$(NPM) run ci-lint
|
|
|
|
.PHONY: test
|
|
test: $(NODE_MODULES) ## Runs the tests
|
|
$(NPM) run test
|
|
@echo Tests pass
|
|
|
|
.PHONY: test-min
|
|
test-min: $(NODE_MODULES) ## Runs the minimal tests
|
|
$(NPM) run test-min
|
|
@echo Tests pass
|
|
|
|
.PHONY: check
|
|
check: $(NODE_MODULES) lint test ## Runs all checks required before committing (fixing trivial things automatically)
|
|
|
|
.PHONY: pre-commit
|
|
pre-commit: $(NODE_MODULES) test-min lint
|
|
|
|
.PHONY: clean
|
|
clean: ## Cleans up everything
|
|
rm -rf node_modules .*-updated .*-bin out
|
|
|
|
.PHONY: prebuild
|
|
prebuild: prereqs
|
|
$(NPM) run webpack
|
|
$(NPM) run ts-compile
|
|
|
|
.PHONY: run-only
|
|
run-only: node-installed ## Runs the site like it runs in production without building it
|
|
env NODE_ENV=production $(NODE) $(NODE_ARGS) ./out/dist/app.js --webpackContent ./out/webpack/static $(EXTRA_ARGS)
|
|
|
|
.PHONY: run
|
|
run: ## Runs the site like it runs in production
|
|
$(MAKE) prebuild
|
|
$(MAKE) run-only
|
|
|
|
.PHONY: dev
|
|
dev: prereqs ## Runs the site as a developer; including live reload support and installation of git hooks
|
|
NODE_OPTIONS=$(NODE_ARGS) ./node_modules/.bin/supervisor -w app.ts,lib,etc/config,static/tsconfig.json -e 'js|ts|node|properties|yaml' -n exit --exec $(shell pwd)/node_modules/.bin/ts-node-esm -- ./app.ts $(EXTRA_ARGS)
|
|
|
|
.PHONY: gpu-dev
|
|
gpu-dev: prereqs ## Runs the site as a developer; including live reload support and installation of git hooks
|
|
NODE_OPTIONS=$(NODE_ARGS) ./node_modules/.bin/supervisor -w app.ts,lib,etc/config,static/tsconfig.json -e 'js|ts|node|properties|yaml' -n exit --exec $(shell pwd)/node_modules/.bin/ts-node-esm -- ./app.ts --env gpu $(EXTRA_ARGS)
|
|
|
|
.PHONY: debug
|
|
debug: prereqs ## Runs the site as a developer with full debugging; including live reload support and installation of git hooks
|
|
NODE_OPTIONS="$(NODE_ARGS) --inspect 9229" ./node_modules/.bin/supervisor -w app.ts,lib,etc/config,static/tsconfig.json -e 'js|ts|node|properties|yaml' -n exit --exec $(shell pwd)/node_modules/.bin/ts-node-esm -- ./app.ts --debug $(EXTRA_ARGS)
|
|
|
|
.PHONY:
|
|
asm-docs:
|
|
$(MAKE) -C etc/scripts/docenizers || ( \
|
|
echo "==============================================================================="; \
|
|
echo "One of the docenizers failed to run, make sure you have installed the necessary"; \
|
|
echo "dependencies: pip3 install beautifulsoup4 pdfminer.six && npm install"; \
|
|
echo "==============================================================================="; \
|
|
exit 1 \
|
|
)
|