Skip to content

Commit 0e2a907

Browse files
committed
refactor: update build scripts
1 parent 0def28c commit 0e2a907

29 files changed

+4455
-1162
lines changed

.prettierignore

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,16 +2,19 @@
22
**/*.log
33
**/.DS_Store
44
*.
5+
.vscode/settings.json
56
.history
67
bazel-*
78
bazel-bin
89
bazel-out
910
bazel-qwik
1011
bazel-testlogs
1112
dist
13+
dist-dev
1214
etc
1315
external
1416
node_modules
1517
temp
1618
tsc-out
1719
tsdoc-metadata.json
20+
integration/**/*.js

BUILD.bazel

Lines changed: 20 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -1,26 +1,24 @@
1-
load("@build_bazel_rules_nodejs//:index.bzl", "copy_to_bin")
2-
load("@npm//@bazel/typescript:index.bzl", "ts_config")
1+
load("//scripts:package_build.bzl", "package_build")
32

43
package(default_visibility = ["//visibility:public"])
54

6-
ts_config(
7-
name = "tsconfig",
8-
src = "tsconfig.json",
5+
package_build(
6+
name = "package",
7+
srcs = glob(
8+
[
9+
"src/**/*.ts",
10+
"src/**/*.tsx",
11+
"integration/devserver.ts",
12+
],
13+
exclude = [
14+
"src/**/*.unit.ts",
15+
"src/**/*.unit.tsx",
16+
],
17+
),
18+
deps = [
19+
":package.json",
20+
":tsconfig.json",
21+
":LICENSE",
22+
":README.md",
23+
]
924
)
10-
11-
copy_to_bin(
12-
name = "package_json",
13-
srcs = [
14-
"package.json",
15-
],
16-
)
17-
18-
exports_files([
19-
"LICENSE",
20-
"README.md",
21-
"core-api-extractor.json",
22-
"cypress.json",
23-
"package.json",
24-
"terser.config.json",
25-
"tsconfig.json",
26-
])

WORKSPACE

Lines changed: 0 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -30,40 +30,3 @@ yarn_install(
3030
package_json = "//:package.json",
3131
yarn_lock = "//:yarn.lock",
3232
)
33-
34-
load("@npm//@bazel/cypress:index.bzl", "cypress_repository")
35-
36-
# The name you pass here names the external repository you can load cypress_web_test from
37-
cypress_repository(name = "cypress")
38-
39-
_ESBUILD_VERSION = "0.11.14" # reminder: update SHAs below when changing this value
40-
41-
http_archive(
42-
name = "esbuild_darwin",
43-
build_file_content = """exports_files(["bin/esbuild"])""",
44-
sha256 = "81c8623c4c03a1fc449c37a90dd630025e334d312420d42106a899f78bd5e3fe",
45-
strip_prefix = "package",
46-
urls = [
47-
"https://registry.npmjs.org/esbuild-darwin-64/-/esbuild-darwin-64-%s.tgz" % _ESBUILD_VERSION,
48-
],
49-
)
50-
51-
http_archive(
52-
name = "esbuild_windows",
53-
build_file_content = """exports_files(["esbuild.exe"])""",
54-
sha256 = "d977751550550099cb9deb95d3fc436c21374b3875131589dde162dfb1c03bf4",
55-
strip_prefix = "package",
56-
urls = [
57-
"https://registry.npmjs.org/esbuild-windows-64/-/esbuild-windows-64-%s.tgz" % _ESBUILD_VERSION,
58-
],
59-
)
60-
61-
http_archive(
62-
name = "esbuild_linux",
63-
build_file_content = """exports_files(["bin/esbuild"])""",
64-
sha256 = "fbf8d42fbd12d2392893a5d8cea3860e875c47ee715660e844dff822b8747321",
65-
strip_prefix = "package",
66-
urls = [
67-
"https://registry.npmjs.org/esbuild-linux-64/-/esbuild-linux-64-%s.tgz" % _ESBUILD_VERSION,
68-
],
69-
)

integration/tsconfig.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
11
{
2-
"extends": "../tsconfig.dev.json",
3-
"include": ["hello_server", "hello_static", "specs", "todo", "devserver.ts"]
2+
"extends": "../tsconfig.json",
3+
"include": ["hello_server", "hello_static", "specs", "todo"]
44
}

package.json

Lines changed: 84 additions & 44 deletions
Original file line numberDiff line numberDiff line change
@@ -1,74 +1,114 @@
11
{
22
"name": "@builder.io/qwik",
3-
"version": "0.0.1",
3+
"version": "0.0.11",
44
"description": "An Open-Source sub-framework designed with a focus on server-side-rendering, lazy-loading, and styling/animation.",
55
"main": "index.js",
6-
"lint-staged": {
7-
"*.*": [
8-
"prettier --write --ignore-unknown"
9-
],
10-
"*.ts": [
11-
"npx eslint"
12-
],
13-
"(WORKSPACE|*.bazel|*.bzl)": [
14-
"npm run bazel:lint-fix"
15-
]
16-
},
176
"@comment type": "Setting type to 'commonjs' is important as many of the bazel tooling assumes 'commonjs'. For code which wants ESM a second 'package.json' file needs to be created for just those files.",
187
"type": "commonjs",
19-
"dependencies": {
20-
"source-map-support": "^0.5.19",
21-
"@bazel/bazelisk": "^1.7.5",
22-
"@bazel/buildifier": "^4.0.1",
23-
"@bazel/cypress": "^3.2.0",
24-
"cypress": "^6.4.0",
25-
"@bazel/esbuild": "^3.6.0",
26-
"@bazel/ibazel": "^0.15.10",
27-
"@bazel/terser": "^3.2.2",
28-
"@bazel/typescript": "3.2.0",
29-
"@microsoft/api-extractor": "^7.13.2",
30-
"@types/chai": "^4.2.15",
31-
"@types/express": "^4.17.9",
32-
"@types/mocha": "^8.2.1",
8+
"devDependencies": {
9+
"@microsoft/api-extractor": "^7.16.1",
10+
"@types/express": "^4.17.13",
11+
"@types/jest": "^26.0.23",
12+
"@types/mri": "^1.1.1",
3313
"@types/node": "^14.14.10",
3414
"@types/source-map-support": "^0.5.3",
3515
"@typescript-eslint/eslint-plugin": "^4.19.0",
3616
"@typescript-eslint/parser": "^4.19.0",
37-
"chai": "^4.3.0",
38-
"commander": "^6.2.0",
17+
"concurrently": "^6.2.0",
18+
"cypress": "^7.7.0",
3919
"domino": "^2.1.6",
20+
"esbuild": "^0.12.13",
21+
"esbuild-register": "^2.6.0",
4022
"eslint": "^7.23.0",
4123
"eslint-plugin-no-only-tests": "^2.4.0",
4224
"express": "^4.17.1",
43-
"http-server": "^0.12.3",
4425
"husky": "^5.2.0",
26+
"jest": "^27.0.5",
4527
"lint-staged": "^10.5.4",
46-
"mocha": "^8.3.0",
28+
"mri": "^1.1.6",
29+
"np": "^7.5.0",
4730
"prettier": "2.3.0",
48-
"serve-static": "^1.14.1",
49-
"terser": "^5.6.0",
31+
"rollup": "^2.52.2",
32+
"source-map-support": "^0.5.19",
33+
"start-server-and-test": "^1.12.6",
34+
"terser": "^5.7.1",
5035
"todomvc-app-css": "^2.3.0",
5136
"todomvc-common": "^1.0.5",
5237
"typescript": "^4.2.0"
5338
},
5439
"scripts": {
40+
"build": "tsc && node scripts && npm run api.ci",
41+
"build.watch": "node scripts --dev --watch",
42+
"tsc.check": "tsc --noEmit",
43+
"tsc.watch": "tsc --noEmit --watch --preserveWatchOutput",
44+
"start": "concurrently \"npm:build.watch\" \"npm:test.watch\" \"npm:tsc.watch\" -n build,test,tsc -c green,magenta,cyan",
45+
"api": "tsc && node -r esbuild-register scripts/api.ts",
46+
"api.ci": "node -r esbuild-register scripts/api.ts",
47+
"api.update": "tsc && node -r esbuild-register scripts/api.ts --dev",
48+
"release": "npm run build && npm run validate && np --contents dist-dev/@builder.io-qwik --no-2fa",
49+
"test": "npm run build && jest && npm run test.e2e",
50+
"test.unit": "jest",
51+
"test.watch": "jest --watch",
52+
"test.e2e": "start-server-and-test integration.server.prod http://localhost:8081 \"cypress run\"",
53+
"test.e2e.open": "start-server-and-test integration.server.prod http://localhost:8081 \"cypress open\"",
54+
"integration.server": "node scripts --dev && node integration/devserver.js --port 8080 --mode development",
55+
"integration.server.prod": "tsc && node scripts && node integration/devserver.js --port 8081 --mode production",
56+
"validate": "node -r esbuild-register scripts/validate.ts",
57+
"prepare": "husky install",
58+
"lint": "eslint \"**/*.ts*\" && npm run prettier-check",
59+
"prettier-check": "prettier --check .",
60+
"prettier-fix": "prettier --write .",
5561
"patch-m1": "npm run patch-m1-bazel && npm run patch-m1-ibazel && npm run patch-m1-buildifier",
5662
"patch-m1-bazel": "echo Patching Bazel for Apple M1 architecture compatibility && ln -fs ./bazelisk-darwin_amd64 node_modules/@bazel/bazelisk/bazelisk-darwin_arm64",
5763
"patch-m1-ibazel": "echo Patching iBazel for Apple M1 architecture compatibility && sed -i .bak \"s/'x64' : 'amd64',\\$/'x64' : 'amd64', 'arm64' : 'amd64',/\" ./node_modules/@bazel/ibazel/index.js",
5864
"patch-m1-buildifier": "echo Patching Buildifier for Apple M1 architecture compatibility && sed -i .bak \"s/'x64' : 'amd64',\\$/'x64' : 'amd64', 'arm64' : 'amd64',/\" ./node_modules/@bazel/buildifier/buildifier.js",
59-
"integration:server": "bazel run //integration:devserver",
60-
"test:unit": "bazel test --test_tag_filters=unit //...",
61-
"test:e2e": "bazel test --test_tag_filters=e2e //...",
62-
"test": "bazel test //...",
63-
"lint": "eslint \"**/*.ts*\"",
64-
"prettier-check": "prettier --check .",
65-
"prettier-fix": "prettier --write .",
6665
"bazel:format": "find . -type f \\( -name \"*.bzl\" -or -name WORKSPACE -or -name BUILD -or -name BUILD.bazel \\) ! -path \"*/node_modules/*\" | xargs buildifier --warnings=attr-cfg,attr-license,attr-non-empty,attr-output-default,attr-single-file,constant-glob,ctx-actions,ctx-args,depset-iteration,depset-union,dict-concatenation,duplicated-name,filetype,git-repository,http-archive,integer-division,load,load-on-top,native-build,native-package,out-of-order-load,output-group,package-name,package-on-top,positional-args,redefined-variable,repository-name,same-origin-load,string-iteration,unsorted-dict-items,unused-variable",
6766
"bazel:lint": "npm run bazel:format -- --mode=check --lint=warn",
68-
"bazel:lint-fix": "npm run bazel:format -- --mode=fix --lint=fix",
69-
"cypress": "cypress open",
70-
"prepare": "husky install"
67+
"bazel:lint-fix": "npm run bazel:format -- --mode=fix --lint=fix"
68+
},
69+
"contributors": [
70+
{
71+
"name": "Miško Hevery",
72+
"email": "misko@hevery.com",
73+
"url": "https://github.com/BuilderIO/qwik"
74+
},
75+
{
76+
"name": "Adam Bradley",
77+
"email": "adam@builder.io",
78+
"url": "https://twitter.com/adamdbradley"
79+
}
80+
],
81+
"license": "MIT",
82+
"homepage": "https://github.com/BuilderIO/qwik#readme",
83+
"repository": {
84+
"type": "git",
85+
"url": "https://github.com/BuilderIO/qwik"
7186
},
72-
"author": "Miško Hevery <misko@hevery.com>",
73-
"license": "MIT"
87+
"bugs": {
88+
"url": "https://github.com/BuilderIO/qwik/issues"
89+
},
90+
"keywords": [
91+
"ssr",
92+
"server-side-render",
93+
"prerender",
94+
"ssg",
95+
"static-site-generator",
96+
"static-site",
97+
"generator",
98+
"website",
99+
"webapp",
100+
"framework",
101+
"Builder.io"
102+
],
103+
"engines": {
104+
"node": ">= 14.14"
105+
},
106+
"lint-staged": {
107+
"*.*": [
108+
"prettier --write --ignore-unknown"
109+
],
110+
"*.ts": [
111+
"npx eslint"
112+
]
113+
}
74114
}

scripts/BUILD.bazel

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
load("@build_bazel_rules_nodejs//:index.bzl", "nodejs_binary")
2+
3+
package(default_visibility = ["//visibility:public"])
4+
5+
# This defines the binary we want as part of the rule.
6+
nodejs_binary(
7+
name = "package_build_binary",
8+
entry_point = ":index.js",
9+
)
10+
11+
filegroup(
12+
name = "all_ts",
13+
srcs = glob(
14+
[
15+
"shim/__dirname.js",
16+
"*.ts*",
17+
],
18+
),
19+
)

scripts/build.ts

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
import { buildDevServer } from './devserver';
2+
import { copyFiles } from './copy-files';
3+
import { generatePackageJson } from './package-json';
4+
import { submoduleCore } from './submodule-core';
5+
import { submoduleJsxRuntime } from './submodule-jsx-runtime';
6+
import { submoduleOptimizer } from './submodule-optimizer';
7+
import { submoduleQwikLoader } from './submodule-qwikloader';
8+
import { submoduleServer } from './submodule-server';
9+
import { submoduleTesting } from './submodule-testing';
10+
import { mkdirSync, rmSync } from 'fs';
11+
import type { BuildConfig } from './util';
12+
13+
export async function build(config: BuildConfig) {
14+
try {
15+
if (!config.dev) {
16+
rmSync(config.pkgDir, { recursive: true, force: true });
17+
}
18+
try {
19+
// ensure the build pkgDir exists
20+
mkdirSync(config.pkgDir, { recursive: true });
21+
} catch (e) {}
22+
23+
await Promise.all([
24+
submoduleCore(config),
25+
submoduleJsxRuntime(config),
26+
submoduleQwikLoader(config),
27+
submoduleServer(config),
28+
submoduleTesting(config),
29+
generatePackageJson(config),
30+
copyFiles(config),
31+
buildDevServer(config),
32+
]);
33+
34+
await submoduleOptimizer(config);
35+
} catch (e) {
36+
console.error(e);
37+
}
38+
}

scripts/copy-files.ts

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
import type { BuildConfig } from './util';
2+
import { copyFile } from 'fs/promises';
3+
import { basename, join } from 'path';
4+
5+
export async function copyFiles(config: BuildConfig) {
6+
const rootFiles = ['README.md', 'LICENSE'];
7+
8+
await Promise.all(
9+
rootFiles.map((f) => {
10+
copyFile(join(config.rootDir, f), join(config.pkgDir, basename(f)));
11+
})
12+
);
13+
}

scripts/devserver.ts

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
import { build } from 'esbuild';
2+
import { join } from 'path';
3+
import { BuildConfig, importPath, watcher } from './util';
4+
5+
export async function buildDevServer(config: BuildConfig) {
6+
const integrationDir = join(config.rootDir, 'integration');
7+
8+
const r = await build({
9+
entryPoints: [join(integrationDir, 'devserver.ts')],
10+
outdir: integrationDir,
11+
bundle: true,
12+
format: 'cjs',
13+
platform: 'node',
14+
sourcemap: 'external',
15+
watch: watcher(config),
16+
external: ['esbuild', 'express', 'mri', 'source-map-support'],
17+
plugins: [importPath(/^@builder\.io\/qwik\/optimizer$/, join(config.pkgDir, 'optimizer.cjs'))],
18+
});
19+
}

0 commit comments

Comments
 (0)