Skip to content

fix(rollup): allow config files to override default onwarn method - #2108

Merged
alexeagle merged 2 commits into
bazel-contrib:stablefrom
jbedard:2084-rollup-onwarn
Sep 9, 2020
Merged

alexeagle merged 2 commits into
bazel-contrib:stablefrom
jbedard:2084-rollup-onwarn

Conversation

@jbedard

@jbedard jbedard commented Aug 12, 2020

Copy link
Copy Markdown
Collaborator

Fixes #2084

... will try adding a test still.

@jbedard

jbedard commented Aug 12, 2020

Copy link
Copy Markdown
Collaborator Author

Interesting this is now throwing:

(node:42) UnhandledPromiseRejectionWarning: Error: 'date-fns' is imported by node_modules/@foo/lib/index.js, but could not be resolved – treating it as an external dependency
    at Object.onwarn (/b/f/w/bazel-out/k8-fastbuild/bin/packages/rollup/test/integration/_bundle.umd.rollup_config.js.cjs.js:34:11)
    at Graph.onwarn (/b/f/w/node_modules/rollup/dist/shared/rollup.js:17999:25)
    at Graph.warn (/b/f/w/node_modules/rollup/dist/shared/rollup.js:17803:14)
    at ModuleLoader.handleResolveId (/b/f/w/node_modules/rollup/dist/shared/rollup.js:16823:24)
    at /b/f/w/node_modules/rollup/dist/shared/rollup.js:16709:26
    at async Promise.all (index 0)
    at async Promise.all (index 2)
    at async Promise.all (index 0)
    at async Promise.all (index 0)
    at async Promise.all (index 0)

However the ts_project using date-fns does have it in the deps. Is that because the rollup_bundle(entry_point) doesn't pull in the deps of that entry_point?

@alexeagle ?

@jbedard
jbedard force-pushed the 2084-rollup-onwarn branch from f4379f5 to 43901d6 Compare August 13, 2020 03:05
@jbedard
jbedard requested a review from alexeagle August 14, 2020 19:52
@jbedard
jbedard force-pushed the 2084-rollup-onwarn branch from 43901d6 to bc62fa1 Compare August 16, 2020 21:09
@jbedard
jbedard marked this pull request as ready for review September 1, 2020 02:10
@jbedard

jbedard commented Sep 1, 2020

Copy link
Copy Markdown
Collaborator Author

@alexeagle @mistic note the change to the integration tests in the second commit.. should that be required? Is js_library not passing the ts_project(deps) along properly?

The rollup rule that test runs was not failing previously due to the bug this PR is fixing.

@mistic

mistic commented Sep 1, 2020

Copy link
Copy Markdown
Contributor

@jbedard there is no way js_library could get the the transitive dependencies with the inputs you're using. You'll have to replace "user.d.ts", ":index.js", by ":tsconfig"

@mistic

mistic commented Sep 1, 2020 •

Copy link
Copy Markdown
Contributor

@jbedard I think you removed ":user.js", by mistake

Probably the following will work:

js_library(
    name = "foo_lib",
    package_name = "@foo/lib",
    srcs = [
        ":foo_tslib",
        ":user.js",
    ],
)

@jbedard

jbedard commented Sep 1, 2020

Copy link
Copy Markdown
Collaborator Author

Thanks @mistic. Depending on the ts_project rule (instead of individual output files) is what I would have expected in the first place, idk why the test was written this way? But this rollup fix exposed that issue 🤷

@jbedard

jbedard commented Sep 1, 2020

Copy link
Copy Markdown
Collaborator Author

Yet the error remains...? 🤔

@mistic

mistic commented Sep 1, 2020

Copy link
Copy Markdown
Contributor

@jbedard I think the changes we discuss offline will now make the CI pass! My suggestion above was wrong and the output from the ts_project rule should be a dep for js_library

@alexeagle
alexeagle merged commit 0b80f6a into bazel-contrib:stable Sep 9, 2020
@jbedard

jbedard commented Sep 9, 2020

Copy link
Copy Markdown
Collaborator Author

FWIW I never found an easy way to test this in my brief attempt. Thanks for merging.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

rollup_bundle overrides onwarn in worker mode

4 participants