Skip to content

Commit

Permalink
refactor(@angular/ssr): switch from esbuild to rollup for bundling cr…
Browse files Browse the repository at this point in the history
…itters/beasties

Esbuild exhibits issues when handling code that is generated and then reprocessed by itself, creating challenges when using it to bundle libraries or library components.

To remove these issues, we've replaced Esbuild with Rollup for bundling `beasties`.

See:  evanw/esbuild#3723
  • Loading branch information
alan-agius4 committed Oct 28, 2024
1 parent 54f0e4c commit 44c4947
Show file tree
Hide file tree
Showing 6 changed files with 168 additions and 240 deletions.
3 changes: 3 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -83,11 +83,13 @@
"@bazel/buildifier": "7.3.1",
"@bazel/concatjs": "patch:@bazel/concatjs@npm%3A5.8.1#~/.yarn/patches/@bazel-concatjs-npm-5.8.1-1bf81df846.patch",
"@bazel/jasmine": "patch:@bazel/jasmine@npm%3A5.8.1#~/.yarn/patches/@bazel-jasmine-npm-5.8.1-3370fee155.patch",
"@bazel/rollup": "^5.8.1",
"@bazel/runfiles": "^5.8.1",
"@discoveryjs/json-ext": "0.6.2",
"@inquirer/confirm": "5.0.0",
"@inquirer/prompts": "7.0.0",
"@listr2/prompt-adapter-inquirer": "2.0.17",
"@rollup/plugin-alias": "^5.1.1",
"@rollup/plugin-commonjs": "^28.0.0",
"@rollup/plugin-node-resolve": "^13.0.5",
"@stylistic/eslint-plugin": "^2.8.0",
Expand Down Expand Up @@ -184,6 +186,7 @@
"quicktype-core": "23.0.170",
"resolve-url-loader": "5.0.0",
"rollup": "4.24.0",
"rollup-license-plugin": "^3.0.0",
"rollup-plugin-sourcemaps": "^0.6.0",
"rxjs": "7.8.1",
"sass": "1.80.4",
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@

--------------------------------------------------------------------------------
Package: beasties
License: "Apache-2.0"
License: Apache-2.0

Apache License
Version 2.0, January 2004
Expand Down Expand Up @@ -207,12 +207,12 @@ Apache License
limitations under the License.
--------------------------------------------------------------------------------
Package: boolbase
License: "ISC"
License: ISC


--------------------------------------------------------------------------------
Package: css-select
License: "BSD-2-Clause"
License: BSD-2-Clause

Copyright (c) Felix Böhm
All rights reserved.
Expand All @@ -227,7 +227,7 @@ THIS IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRE
EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
--------------------------------------------------------------------------------
Package: css-what
License: "BSD-2-Clause"
License: BSD-2-Clause

Copyright (c) Felix Böhm
All rights reserved.
Expand All @@ -242,7 +242,7 @@ THIS IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRE
EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
--------------------------------------------------------------------------------
Package: dom-serializer
License: "MIT"
License: MIT

License

Expand All @@ -257,7 +257,7 @@ The above copyright notice and this permission notice shall be included in all c
THE SOFTWARE IS PROVIDED 'AS IS', WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
--------------------------------------------------------------------------------
Package: domelementtype
License: "BSD-2-Clause"
License: BSD-2-Clause

Copyright (c) Felix Böhm
All rights reserved.
Expand All @@ -272,7 +272,7 @@ THIS IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRE
EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
--------------------------------------------------------------------------------
Package: domhandler
License: "BSD-2-Clause"
License: BSD-2-Clause

Copyright (c) Felix Böhm
All rights reserved.
Expand All @@ -287,7 +287,7 @@ THIS IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRE
EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
--------------------------------------------------------------------------------
Package: domutils
License: "BSD-2-Clause"
License: BSD-2-Clause

Copyright (c) Felix Böhm
All rights reserved.
Expand All @@ -302,7 +302,7 @@ THIS IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRE
EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
--------------------------------------------------------------------------------
Package: entities
License: "BSD-2-Clause"
License: BSD-2-Clause

Copyright (c) Felix Böhm
All rights reserved.
Expand All @@ -317,7 +317,7 @@ THIS IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRE
EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
--------------------------------------------------------------------------------
Package: htmlparser2
License: "MIT"
License: MIT

Copyright 2010, 2011, Chris Winberry <[email protected]>. All rights reserved.
Permission is hereby granted, free of charge, to any person obtaining a copy
Expand All @@ -339,7 +339,7 @@ FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
IN THE SOFTWARE.
--------------------------------------------------------------------------------
Package: nanoid
License: "MIT"
License: MIT

The MIT License (MIT)

Expand All @@ -363,7 +363,7 @@ IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
--------------------------------------------------------------------------------
Package: nth-check
License: "BSD-2-Clause"
License: BSD-2-Clause

Copyright (c) Felix Böhm
All rights reserved.
Expand All @@ -378,7 +378,7 @@ THIS IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRE
EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
--------------------------------------------------------------------------------
Package: pathe
License: "MIT"
License: MIT

MIT License

Expand Down Expand Up @@ -426,7 +426,7 @@ OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE
USE OR OTHER DEALINGS IN THE SOFTWARE.
--------------------------------------------------------------------------------
Package: picocolors
License: "ISC"
License: ISC

ISC License

Expand All @@ -445,7 +445,7 @@ ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
--------------------------------------------------------------------------------
Package: postcss
License: "MIT"
License: MIT

The MIT License (MIT)

Expand All @@ -469,12 +469,12 @@ IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
--------------------------------------------------------------------------------
Package: postcss-media-query-parser
License: "MIT"
License: MIT


--------------------------------------------------------------------------------
Package: unenv
License: "MIT"
License: MIT

MIT License

Expand Down
39 changes: 21 additions & 18 deletions packages/angular/ssr/third_party/beasties/BUILD.bazel
Original file line number Diff line number Diff line change
@@ -1,25 +1,8 @@
load("@npm//@angular/build-tooling/bazel/esbuild:index.bzl", "esbuild", "esbuild_config")
load("@npm//@bazel/rollup:index.bzl", "rollup_bundle")
load("//tools:defaults.bzl", "js_library")

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

esbuild(
name = "bundled_beasties",
config = ":esbuild_config",
entry_point = "@npm//:node_modules/beasties/dist/index.mjs",
metafile = True,
splitting = True,
deps = [
"@npm//beasties",
"@npm//unenv",
],
)

esbuild_config(
name = "esbuild_config",
config_file = "esbuild.config.mjs",
)

js_library(
name = "bundled_beasties_lib",
srcs = [
Expand Down Expand Up @@ -53,3 +36,23 @@ genrule(
done
""",
)

rollup_bundle(
name = "bundled_beasties",
config_file = ":rollup.config.mjs",
entry_points = {
"@npm//:node_modules/beasties/dist/index.mjs": "index",
},
format = "esm",
link_workspace_root = True,
output_dir = True,
sourcemap = "true",
deps = [
"@npm//@rollup/plugin-alias",
"@npm//@rollup/plugin-commonjs",
"@npm//@rollup/plugin-node-resolve",
"@npm//beasties",
"@npm//rollup-license-plugin",
"@npm//unenv",
],
)
Loading

0 comments on commit 44c4947

Please sign in to comment.