Skip to content
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

rollup_bundle srcs are not visible to files reachable from entry_point #1698

Closed
duarten opened this issue Mar 9, 2020 · 5 comments
Closed
Labels
Can Close? We will close this in 30 days if there is no further activity

Comments

@duarten
Copy link
Contributor

duarten commented Mar 9, 2020

🐞 bug report

Affected Rule

The issue is caused by the rule:

rollup_bundle()

Description

Including a file in the rollup_bundle srcs doesn't make it available to entry_point files.

Assuming I add tailwind.css to srcs, it is available at .../execroot/root/pkg/tailwind.css. My index file, on the other hand, is at .../execroot/root/bazel-out/darwin-dbg/bin/pkg/src/index.mjs.

🔬 Minimal Reproduction

ts_library(
    name = "lib",
    srcs = glob([
        "src/**/*.ts",
    ]),
    tsconfig = "tsconfig",
    deps = [
    ],
)

rollup_bundle(
    name = "bundle",
    srcs = [
        "tailwind.css",
    ],
    config_file = "rollup.config.js",
    entry_point = "src/index.ts",
    format = "iife",
    output_dir = False,
    sourcemap = "inline",
    deps = [":lib"]

🔥 Exception or Error


[!] Error: Could not resolve '../tailwind.css' from bazel-out/darwin-dbg/bin/pkg/src/index.mjs

🌍 Your Environment

Operating System:

  
  macOS
  

Output of bazel version:

  
Build label: 2.1.0
Build target: bazel-out/darwin-opt/bin/src/main/java/com/google/devtools/build/lib/bazel/BazelServer_deploy.jar
Build time: Fri Feb 7 13:04:00 2020 (1581080640)
Build timestamp: 1581080640
Build timestamp as int: 1581080640
  

Rules_nodejs version:

(Please check that you have matching versions between WORKSPACE file and @bazel/* npm packages.)

  
1.3.0
  

Anything else relevant?

@duarten
Copy link
Contributor Author

duarten commented Apr 17, 2020

The same thing happens to data carried from a dependency to rollup_bundle.

Assume this change to the rule:

diff --git a/packages/rollup/src/rollup_bundle.bzl b/packages/rollup/src/rollup_bundle.bzl
index f5cf732d..3b2abb76 100644
--- a/packages/rollup/src/rollup_bundle.bzl
+++ b/packages/rollup/src/rollup_bundle.bzl
@@ -394,7 +394,13 @@ def _rollup_bundle(ctx):
     )

     return [
-        DefaultInfo(files = depset(outputs)),
+        DefaultInfo(
+            files = depset(outputs),
+            runfiles = ctx.runfiles(
+                collect_default = True,
+                collect_data = True,
+            ),
+        ),
     ]

 rollup_bundle = rule(

Then, the rules:

ts_library(
    name = "lib",
    srcs = glob([
        "src/**/*.ts",
    ]),
    tsconfig = "tsconfig",
    data = [file.json],
)

rollup_bundle(
    name = "bundle",
    config_file = "rollup.config.js",
    entry_point = "src/index.ts",
    format = "iife",
    output_dir = False,
    sourcemap = "inline",
    deps = [":lib"]

Then, in rollup's run_files, the js files of lib will be under bazel-out, but the data file will not. This will break the import paths and rollup will be unable to find file.json.

Is the correct fix should be to have ts_library link the data files in the bazel-out dir with the output js files to preserve import paths?

@0xflick
Copy link

0xflick commented Jun 9, 2020

I think I'm running into an issue with this root cause. In the meantime is there any way to make css visible via rollup?

@0xflick
Copy link

0xflick commented Jun 9, 2020

Ended up using copy_to_bin as suggested in #1771. However, it would be great if this use case was better supported.

@github-actions
Copy link

This issue has been automatically marked as stale because it has not had any activity for 60 days. It will be closed if no further activity occurs in two weeks. Collaborators can add a "cleanup" or "need: discussion" label to keep it open indefinitely. Thanks for your contributions to rules_nodejs!

@github-actions github-actions bot added the Can Close? We will close this in 30 days if there is no further activity label Sep 15, 2020
@github-actions
Copy link

github-actions bot commented Oct 1, 2020

This issue was automatically closed because it went two weeks without a reply since it was labeled "Can Close?"

@github-actions github-actions bot closed this as completed Oct 1, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Can Close? We will close this in 30 days if there is no further activity
Projects
None yet
Development

No branches or pull requests

3 participants