mirror of
https://github.com/denoland/deno.git
synced 2024-11-21 15:04:11 -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") {
|
||||
main_source = "$target_gen_dir/tsc_dist/main.js"
|
||||
main_output = "$target_gen_dir/bundle/main.js"
|
||||
out_dir = "$target_gen_dir/bundle/"
|
||||
sources = [
|
||||
main_source,
|
||||
"$target_gen_dir/tsc_dist/main.js", # Not real input. See run_tsc comment.
|
||||
"js/main.ts",
|
||||
]
|
||||
outputs = [
|
||||
main_output,
|
||||
out_dir + "main.js",
|
||||
]
|
||||
deps = [
|
||||
":run_tsc",
|
||||
]
|
||||
args = [
|
||||
"./node_modules/browserify/bin/cmd.js",
|
||||
rebase_path(main_source, root_build_dir),
|
||||
"-o",
|
||||
rebase_path(main_output, root_build_dir),
|
||||
"./node_modules/parcel-bundler/bin/cli.js",
|
||||
"build",
|
||||
"--no-minify",
|
||||
"--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") {
|
||||
main_source = "js/main.ts"
|
||||
main = "js/main.ts"
|
||||
tsconfig = "js/tsconfig.json"
|
||||
out_dir = "$target_gen_dir/tsc_dist/"
|
||||
sources = [
|
||||
#"js/msg.pb.d.ts",
|
||||
"js/msg.pb.d.ts",
|
||||
"js/msg.pb.js",
|
||||
"js/tsconfig.json",
|
||||
main_source,
|
||||
main,
|
||||
tsconfig,
|
||||
]
|
||||
out_dir = "$target_gen_dir/tsc_dist"
|
||||
outputs = [
|
||||
out_dir + "/main.js",
|
||||
out_dir + "/main.map",
|
||||
]
|
||||
deps = [
|
||||
":pbjs_hack",
|
||||
":protobufjs",
|
||||
]
|
||||
args = [
|
||||
"./node_modules/typescript/bin/tsc",
|
||||
"-p",
|
||||
rebase_path("js/tsconfig.json", root_build_dir),
|
||||
"--project",
|
||||
rebase_path(tsconfig, root_build_dir),
|
||||
"--outDir",
|
||||
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"
|
||||
sources = [
|
||||
"msg.proto",
|
||||
|
|
|
@ -1,10 +1,7 @@
|
|||
{
|
||||
"devDependencies": {
|
||||
"@types/base64-js": "^1.2.5",
|
||||
"@types/source-map-support": "^0.4.1",
|
||||
"browserify": "^16.2.2",
|
||||
"parcel-bundler": "^1.8.1",
|
||||
"protobufjs": "^6.8.6",
|
||||
"source-map-support": "^0.5.6",
|
||||
"typescript": "^2.9.1"
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,16 +1,21 @@
|
|||
#!/usr/bin/env python
|
||||
"""
|
||||
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.
|
||||
therefore we write them into the source directory.
|
||||
|
||||
Generates protobufjs code.
|
||||
"""
|
||||
import subprocess
|
||||
import sys
|
||||
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__))
|
||||
#bin_path = os.path.join(js_path, "deno_protobufjs", "bin")
|
||||
pbjs_path = os.path.join(js_path, "node_modules", "protobufjs", "bin")
|
||||
pbjs_bin = os.path.join(pbjs_path, "pbjs")
|
||||
pbts_bin = os.path.join(pbjs_path, "pbts")
|
||||
|
@ -31,7 +36,6 @@ def touch(fname):
|
|||
subprocess.check_call([
|
||||
"node",
|
||||
pbjs_bin,
|
||||
#"--dependency=./deno_protobufjs/minimal",
|
||||
"--target=static-module",
|
||||
"--wrapper=commonjs",
|
||||
"--out=" + msg_pbjs_out,
|
||||
|
|
|
@ -1,6 +1,8 @@
|
|||
#!/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 sys
|
||||
|
@ -23,7 +25,6 @@ def symlink(target, name, target_is_dir=False):
|
|||
js_path = os.path.dirname(os.path.realpath(__file__))
|
||||
node_modules_path = os.path.join(js_path, "node_modules")
|
||||
|
||||
# root_out_dir
|
||||
if not os.path.exists("node_modules"):
|
||||
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