Skip to content
This repository has been archived by the owner on Feb 19, 2020. It is now read-only.

Upgrade build pipeline and remove n8-make #228

Merged
merged 1 commit into from
Jan 27, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
4 changes: 3 additions & 1 deletion .eslintrc.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
module.exports = {
root: true,
parser: 'babel-eslint',
parserOptions: {
sourceType: 'module'
},
env: {
browser: true,
mocha: true,
Expand Down
85 changes: 33 additions & 52 deletions Makefile
Original file line number Diff line number Diff line change
@@ -1,85 +1,66 @@
# get Makefile directory name: http://stackoverflow.com/a/5982798/376773
THIS_MAKEFILE_PATH:=$(word $(words $(MAKEFILE_LIST)),$(MAKEFILE_LIST))
THIS_DIR:=$(shell cd $(dir $(THIS_MAKEFILE_PATH));pwd)
babel = node_modules/.bin/babel
webpack = node_modules/.bin/webpack
eslint = node_modules/.bin/eslint
mocha = node_modules/.bin/mocha

ROOT := lib/ index.js
include $(shell node -e "require('n8-make')")
# Source files root directory
ROOT := lib index.js

# BIN directory
BIN := $(THIS_DIR)/node_modules/.bin
# The directory to place the compiled .js and .json files.
BUILDDIR = build

# Testing WEB APP port
TESTAPP_DIR := webapp/tests
TESTAPP_PORT := 3001
SOURCE_FILES = $(shell find $(ROOT) -name "*.js")
COMPILED_FILES = $(addprefix $(BUILDDIR)/, $(SOURCE_FILES))

# Files
JS_FILES := $(wildcard index.js lib/*.js test/*.js)
JS_FILES := $(SOURCE_FILES) $(wildcard test/*.js)
JS_TESTING_FILES := $(wildcard test/test*.js test-whitelist/test*.js)

# applications
NODE ?= node
NPM ?= $(NODE) $(shell which npm)
MOCHA ?= $(NODE) $(BIN)/mocha
WEBPACK ?= $(NODE) $(BIN)/webpack
all: build build/wpcom.js

standalone: compile build/wpcom.js
build: $(COMPILED_FILES)

compile:
make build --jobs=8
$(BUILDDIR)/%.js: %.js
@mkdir -p $(dir $@)
@echo JS source file: "$<" → "$@"
@$(babel) "$<" --source-maps --out-file "$@"

build/wpcom.js:
@$(WEBPACK) -p --config ./webpack.config.js
build/wpcom.js: build
@$(webpack) --config ./webpack.config.js

install: node_modules

node_modules:
@NODE_ENV= $(NPM) install
@npm install
@touch node_modules

lint: node_modules/eslint node_modules/babel-eslint
@$(BIN)/eslint $(JS_FILES)
lint:
@$(eslint) $(JS_FILES)

eslint: lint

test:
@$(MOCHA) \
@$(mocha) \
--timeout 120s \
--slow 3s \
--grep "$(FILTER)" \
--bail \
--reporter spec \
--compilers js:babel-register \
--require @babel/register \
test/

test-watch:
@$(MOCHA) \
@$(mocha) \
--timeout 120s \
--slow 3s \
--bail \
--reporter spec \
--compilers js:babel-register \
--require @babel/register \
--watch \
--grep "$(FILTER)" \
test/

webapp:
@$(WEBPACK) -p --config webapp/webpack.config.js

media-editor:
@$(WEBPACK) -p --config examples/media-editor/webpack.config.js

deploy: webapp media-editor
mkdir -p tmp/
rm -rf tmp/*
mkdir -p tmp/tests
mkdir -p tmp/media-editor
cp webapp/index.html tmp/
cp webapp/style.css tmp/
cp webapp/webapp-bundle.js tmp/
cp examples/media-editor/index.html tmp/media-editor
cp examples/media-editor/app.css tmp/media-editor
cp -rf examples/media-editor/built/ tmp/media-editor/built
git checkout gh-pages
cp -rf tmp/* .

.PHONY: standalone test test-all node_modules lint eslint webapp compile
clean:
@rm -rfv $(BUILDDIR)

distclean:
@rm -rfv node_modules
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should distclean run clean too? It seems odd for it to clear node_modules but leave previously built files behind.


.PHONY: all test test-watch node_modules lint eslint clean distclean
13 changes: 13 additions & 0 deletions babel.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
module.exports = {
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm wondering if we should use calypso-build for this, to ensure config compatibility. Then again, I expect this will only be used for the standalone bundle, while it exists outside of the monorepo?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

My intent here was to do some cleanups before importing this project to the Calypso monorepo. Then it will use calypso-build. At that time, it won't be a huge upgrade of everything, but just a little change that ideally won't change the build output at all.

presets: [
[
'@babel/env',
{
useBuiltIns: 'usage',
corejs: 2,
exclude: [ 'transform-typeof-symbol' ],
},
],
],
plugins: [ '@babel/transform-runtime' ],
};