-
Notifications
You must be signed in to change notification settings - Fork 24.8k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
build(ivy): create hello world rollup #22004
Conversation
You can preview dfcd36d at https://pr22004-dfcd36d.ngbuilds.io/. |
dfcd36d
to
16af609
Compare
16af609
to
0352989
Compare
You can preview 16af609 at https://pr22004-16af609.ngbuilds.io/. |
You can preview 0352989 at https://pr22004-0352989.ngbuilds.io/. |
b22fcee
to
4ac0f20
Compare
You can preview 4ac0f20 at https://pr22004-4ac0f20.ngbuilds.io/. |
WORKSPACE
Outdated
remote = "https://github.com/bazelbuild/rules_nodejs.git", | ||
commit = "230d39a391226f51c03448f91eb61370e2e58c42", | ||
remote = "https://github.com/alexeagle/rules_nodejs.git", | ||
commit = "6a4b9aa32677cbab3dfed48b9b4eda13d8c41f23", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
please describe why we use custom build and what needs to be done to get back to upstream. Is there an issue/pr tracking the work?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
👍
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Landed the changes, so this now points back to HEAD on the upstream repo master
WORKSPACE
Outdated
git_repository( | ||
name = "angular_devkit", | ||
remote = "https://github.com/alexeagle/devkit.git", | ||
commit = "4b960f37f49a4ed87d54402ce935a4fa0da7b0f6", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
do we need this particular commit? can't we use a tag instead? it's much easier to understand what we use if we use tags.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
yeah this has a pending PR too
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Landed the changes, so this now points back to HEAD on the upstream repo master
packages/bazel/src/BUILD.bazel
Outdated
nodejs_binary( | ||
name = "rollup_with_build_optimizer", | ||
data = ["@angular_devkit//packages/angular_devkit/build_optimizer:lib"], | ||
entry_point = "build_bazel_rules_nodejs_rollup_deps/node_modules/rollup/bin/rollup", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ouch.. really? why do we reach into that external rule? that looks super ugly. can't we do better?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We could have our own external repo to hold the runtime deps, but since this rule extends rollup_bundle I think it's appropriate to share the runtime deps too
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
can you document this reasoning. I'm sure more people will wonder about this in the future when looking at this code.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
👍
|
||
ng_rollup_bundle( | ||
name = "bundle", | ||
# FIXME(alex): should start with "angular/" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
can you capture why it can't be that way now?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It's pretty complicated, basically I want users to see a consistent view that looks like a runfiles view where paths start with the workspace, but in the execroot they don't currently. I need to find the right place to enforce a mapping.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
see.. it's not that complicated after all. your description above is way better than the current fixme note.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
👍
packages/bazel/src/es5_esm.bzl
Outdated
""" | ||
|
||
# The provider downstream rules use to access the outputs | ||
ES5ESMInfo = provider( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
the terminology, we usually use for this is ESM5 not ES5ESM. see https://docs.google.com/document/d/1CZC2rcpxffTDfRDs6p1cfbmKNLA6x5O-NtkJglDaBVs/preview
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
renamed
packages/bazel/src/es5_esm.bzl
Outdated
return [] | ||
|
||
# We create a new tsconfig.json file that will have our compilation settings | ||
tsconfig = ctx.actions.declare_file("%s_es5_esm.tsconfig.json" % target.label.name) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
esm5.tsconfig.json
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
done
packages/bazel/src/es5_esm.bzl
Outdated
workspace = target.label.workspace_root if target.label.workspace_root else "" | ||
|
||
# re-root the outputs under a ".es5_esm" directory so the path don't collide | ||
out_dir = ctx.label.name + ".es5_esm" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
esm5... throughout the PR
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
yup
data['angularCompilerOptions']['expectedOut'].map( | ||
f => f.replace(/\.closure\.js$/, '.js').replace(binDir, path.join(binDir, newRoot))); | ||
} | ||
fs.writeFileSync(output, JSON.stringify(data), {encoding: 'utf-8'}); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
utf8 is the default for writeFileSync
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
oh
# We don't expect anyone to make use of this ES6 bundle, but it makes this rule | ||
# compatible with rollup_bundle which allows them to be easily swapped back and | ||
# forth. | ||
es6_rollup_config = write_rollup_config(ctx, filename = "_%s.rollup_es6.conf.js") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
es2015 - can we please be consistent. otherwise it's confusing. esX is no longer a thing. ES2018 has just been finalized: http://2ality.com/2017/02/ecmascript-2018.html
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
well, this is in a lot of places like rules_typescript, so we can't be 100% consistent without a lot of work, but will fix here
.circleci/config.yml
Outdated
@@ -64,6 +64,10 @@ jobs: | |||
# See https://github.com/bazelbuild/bazel/issues/4257 | |||
- run: bazel query --output=label '//modules/... union //packages/... union //tools/...' | xargs bazel test --config=ci | |||
|
|||
- store_artifacts: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
can you document why we do this? via an inline comment.
it's not clear to me how will the size tracking work? using an external service?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
👍
4ac0f20
to
85f77db
Compare
You can preview 85f77db at https://pr22004-85f77db.ngbuilds.io/. |
85f77db
to
5110990
Compare
You can preview 5110990 at https://pr22004-5110990.ngbuilds.io/. |
"""This provides a variant of rollup_bundle that works better for Angular apps. | ||
|
||
It registers @angular-devkit/build-optimizer as a rollup plugin, to get | ||
better optimization. It also uses ES5-ESM format inputs, as this is what |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
esm5
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
👍
"write_rollup_config", | ||
"run_rollup", | ||
"run_uglify") | ||
load("@build_bazel_rules_nodejs//internal:collect_es6_sources.bzl", collect_es2015_sources = "collect_es6_sources") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I filed bazelbuild/rules_nodejs#107
BO_PLUGIN="require('angular_devkit/packages/angular_devkit/build_optimizer/src/build-optimizer/rollup-plugin.js').default()" | ||
|
||
def _ng_rollup_bundle(ctx): | ||
# We don't expect anyone to make use of this ES6 bundle, but it makes this rule |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
it's esm2015 bundle or fesm2015
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
also we do very much expect to start switching over to esm2015 as the primary input to application bundle around the v7 timeframe.
# We don't expect anyone to make use of this ES6 bundle, but it makes this rule | ||
# compatible with rollup_bundle which allows them to be easily swapped back and | ||
# forth. | ||
es2015_rollup_config = write_rollup_config(ctx, filename = "_%s.rollup_es6.conf.js") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
esm2015
# compatible with rollup_bundle which allows them to be easily swapped back and | ||
# forth. | ||
es2015_rollup_config = write_rollup_config(ctx, filename = "_%s.rollup_es6.conf.js") | ||
run_rollup(ctx, collect_es2015_sources(ctx), es2015_rollup_config, ctx.outputs.build_es6) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
where is this output defined? I don't see any other references to "build_es6" in this PR
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
it's in the ROLLUP_OUTPUTS
that we inherit from rules_nodejs
oops.. closed by mistake. sorry! 😇 |
.circleci/config.yml
Outdated
# CircleCI will allow us to go back and view/download these artifacts after each build. | ||
# Also we can use a service like https://buildsize.org/ to automatically track binary size of these artifacts. | ||
- store_artifacts: | ||
path: dist/bin/packages/core/test/bundling/hello_world/bundle.min.js |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this is no exciting!
5110990
to
07795d3
Compare
You can preview 07795d3 at https://pr22004-07795d3.ngbuilds.io/. |
07795d3
to
14dfcd9
Compare
You can preview 14dfcd9 at https://pr22004-14dfcd9.ngbuilds.io/. |
This is a customization of the rollup_bundle rule from rules_nodejs which adds the build-optimizer as a plugin. Add a functional test with fast round-trip that asserts the minified app still works. Publish the min.js artifact on circleCI so we can track its size.
14dfcd9
to
f425a66
Compare
You can preview f425a66 at https://pr22004-f425a66.ngbuilds.io/. |
This is a customization of the rollup_bundle rule from rules_nodejs which adds the build-optimizer as a plugin. Add a functional test with fast round-trip that asserts the minified app still works. Publish the min.js artifact on circleCI so we can track its size. PR Close angular#22004
This is a customization of the rollup_bundle rule from rules_nodejs which adds the build-optimizer as a plugin. Add a functional test with fast round-trip that asserts the minified app still works. Publish the min.js artifact on circleCI so we can track its size. PR Close angular#22004
This issue has been automatically locked due to inactivity. Read more about our automatic conversation locking policy. This action has been performed automatically by a bot. |
This is a customization of the rollup_bundle rule from rules_nodejs
which adds the build-optimizer as a plugin.
Add a functional test with fast round-trip that asserts the minified app
still works.
Publish the min.js artifact on circleCI so we can track its size.