mirror of
https://github.com/denoland/deno.git
synced 2024-11-25 15:29:32 -05:00
Clean up the build (replace browserify with parcel)
This commit is contained in:
parent
1676822888
commit
bb6222c918
5 changed files with 3008 additions and 341 deletions
|
@ -76,51 +76,64 @@ template("run_node") {
|
||||||
}
|
}
|
||||||
|
|
||||||
run_node("bundle") {
|
run_node("bundle") {
|
||||||
main_source = "$target_gen_dir/tsc_dist/main.js"
|
out_dir = "$target_gen_dir/bundle/"
|
||||||
main_output = "$target_gen_dir/bundle/main.js"
|
|
||||||
sources = [
|
sources = [
|
||||||
main_source,
|
"$target_gen_dir/tsc_dist/main.js", # Not real input. See run_tsc comment.
|
||||||
|
"js/main.ts",
|
||||||
]
|
]
|
||||||
outputs = [
|
outputs = [
|
||||||
main_output,
|
out_dir + "main.js",
|
||||||
]
|
]
|
||||||
deps = [
|
deps = [
|
||||||
":run_tsc",
|
":run_tsc",
|
||||||
]
|
]
|
||||||
args = [
|
args = [
|
||||||
"./node_modules/browserify/bin/cmd.js",
|
"./node_modules/parcel-bundler/bin/cli.js",
|
||||||
rebase_path(main_source, root_build_dir),
|
"build",
|
||||||
"-o",
|
"--no-minify",
|
||||||
rebase_path(main_output, root_build_dir),
|
"--out-dir",
|
||||||
|
rebase_path(out_dir, root_build_dir),
|
||||||
|
rebase_path("js/main.ts", root_build_dir),
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
|
|
||||||
|
# Due to bugs in Parcel we must run TSC independently in order to catch errors.
|
||||||
|
# https://github.com/parcel-bundler/parcel/issues/954
|
||||||
run_node("run_tsc") {
|
run_node("run_tsc") {
|
||||||
main_source = "js/main.ts"
|
main = "js/main.ts"
|
||||||
|
tsconfig = "js/tsconfig.json"
|
||||||
|
out_dir = "$target_gen_dir/tsc_dist/"
|
||||||
sources = [
|
sources = [
|
||||||
#"js/msg.pb.d.ts",
|
"js/msg.pb.d.ts",
|
||||||
"js/msg.pb.js",
|
"js/msg.pb.js",
|
||||||
"js/tsconfig.json",
|
main,
|
||||||
main_source,
|
tsconfig,
|
||||||
]
|
]
|
||||||
out_dir = "$target_gen_dir/tsc_dist"
|
|
||||||
outputs = [
|
outputs = [
|
||||||
out_dir + "/main.js",
|
out_dir + "/main.js",
|
||||||
out_dir + "/main.map",
|
out_dir + "/main.map",
|
||||||
]
|
]
|
||||||
deps = [
|
deps = [
|
||||||
":pbjs_hack",
|
":protobufjs",
|
||||||
]
|
]
|
||||||
args = [
|
args = [
|
||||||
"./node_modules/typescript/bin/tsc",
|
"./node_modules/typescript/bin/tsc",
|
||||||
"-p",
|
"--project",
|
||||||
rebase_path("js/tsconfig.json", root_build_dir),
|
rebase_path(tsconfig, root_build_dir),
|
||||||
"--outDir",
|
"--outDir",
|
||||||
rebase_path(out_dir, root_build_dir),
|
rebase_path(out_dir, root_build_dir),
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
|
|
||||||
action("pbjs_hack") {
|
# Generates protobufjs code.
|
||||||
|
# TODO(ry) Ideally protobufjs output files should be written into
|
||||||
|
# target_gen_dir, but its difficult to get this working in a way that the
|
||||||
|
# bundler can resolve their location. (The bundler does not support NODE_PATH?)
|
||||||
|
# Therefore this hack: write the generated msg.pb.js and msg.pb.d.ts outputs
|
||||||
|
# into the js/ folder, and we check them into the repo. Hopefully this hack can
|
||||||
|
# be removed at some point. If msg.proto is changed, commit changes to the
|
||||||
|
# generated JS files. The stamp file is just to make gn work.
|
||||||
|
action("protobufjs") {
|
||||||
script = "js/pbjs_hack.py"
|
script = "js/pbjs_hack.py"
|
||||||
sources = [
|
sources = [
|
||||||
"msg.proto",
|
"msg.proto",
|
||||||
|
|
|
@ -1,10 +1,7 @@
|
||||||
{
|
{
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
"@types/base64-js": "^1.2.5",
|
"parcel-bundler": "^1.8.1",
|
||||||
"@types/source-map-support": "^0.4.1",
|
|
||||||
"browserify": "^16.2.2",
|
|
||||||
"protobufjs": "^6.8.6",
|
"protobufjs": "^6.8.6",
|
||||||
"source-map-support": "^0.5.6",
|
|
||||||
"typescript": "^2.9.1"
|
"typescript": "^2.9.1"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,16 +1,21 @@
|
||||||
#!/usr/bin/env python
|
#!/usr/bin/env python
|
||||||
"""
|
"""
|
||||||
gn can only run python scripts.
|
gn can only run python scripts.
|
||||||
protobuf.js must generate some javascript files.
|
|
||||||
it's very difficult to get this into the gn build sanely.
|
Generates protobufjs code.
|
||||||
therefore we write them into the source directory.
|
|
||||||
"""
|
"""
|
||||||
import subprocess
|
import subprocess
|
||||||
import sys
|
import sys
|
||||||
import os
|
import os
|
||||||
|
# TODO(ry) Ideally protobufjs output files should be written into
|
||||||
|
# target_gen_dir, but its difficult to get this working in a way that parcel can
|
||||||
|
# resolve their location. (Parcel does not support NODE_PATH.) Therefore this
|
||||||
|
# hack: write the generated msg.pb.js and msg.pb.d.ts outputs into the js/
|
||||||
|
# folder, and we check them into the repo. Hopefully this hack can be removed at
|
||||||
|
# some point. If msg.proto is changed, commit changes to the generated JS
|
||||||
|
# files.
|
||||||
|
|
||||||
js_path = os.path.dirname(os.path.realpath(__file__))
|
js_path = os.path.dirname(os.path.realpath(__file__))
|
||||||
#bin_path = os.path.join(js_path, "deno_protobufjs", "bin")
|
|
||||||
pbjs_path = os.path.join(js_path, "node_modules", "protobufjs", "bin")
|
pbjs_path = os.path.join(js_path, "node_modules", "protobufjs", "bin")
|
||||||
pbjs_bin = os.path.join(pbjs_path, "pbjs")
|
pbjs_bin = os.path.join(pbjs_path, "pbjs")
|
||||||
pbts_bin = os.path.join(pbjs_path, "pbts")
|
pbts_bin = os.path.join(pbjs_path, "pbts")
|
||||||
|
@ -31,7 +36,6 @@ def touch(fname):
|
||||||
subprocess.check_call([
|
subprocess.check_call([
|
||||||
"node",
|
"node",
|
||||||
pbjs_bin,
|
pbjs_bin,
|
||||||
#"--dependency=./deno_protobufjs/minimal",
|
|
||||||
"--target=static-module",
|
"--target=static-module",
|
||||||
"--wrapper=commonjs",
|
"--wrapper=commonjs",
|
||||||
"--out=" + msg_pbjs_out,
|
"--out=" + msg_pbjs_out,
|
||||||
|
|
|
@ -1,6 +1,8 @@
|
||||||
#!/usr/bin/env python
|
#!/usr/bin/env python
|
||||||
"""
|
"""
|
||||||
gn can only run python scripts.
|
gn can only run python scripts. This launches a subprocess Node process.
|
||||||
|
The working dir of this program is out/Debug/ (AKA root_build_dir)
|
||||||
|
Before running node, we symlink js/node_modules to out/Debug/node_modules.
|
||||||
"""
|
"""
|
||||||
import subprocess
|
import subprocess
|
||||||
import sys
|
import sys
|
||||||
|
@ -23,7 +25,6 @@ def symlink(target, name, target_is_dir=False):
|
||||||
js_path = os.path.dirname(os.path.realpath(__file__))
|
js_path = os.path.dirname(os.path.realpath(__file__))
|
||||||
node_modules_path = os.path.join(js_path, "node_modules")
|
node_modules_path = os.path.join(js_path, "node_modules")
|
||||||
|
|
||||||
# root_out_dir
|
|
||||||
if not os.path.exists("node_modules"):
|
if not os.path.exists("node_modules"):
|
||||||
symlink(node_modules_path, "node_modules", True)
|
symlink(node_modules_path, "node_modules", True)
|
||||||
|
|
||||||
|
|
3278
deno2/js/yarn.lock
3278
deno2/js/yarn.lock
File diff suppressed because it is too large
Load diff
Loading…
Reference in a new issue