Skip to content

this.warn and this.error are not available in transformBundle #1282

Closed

Description

@Pauan

Here is an example Rollup config:

export default {
  entry: "foo.js",
  format: "es",
  plugins: [
    {
      transformBundle: function (source) {
        console.log(this.warn);
        console.log(this.error);
      }
    }
  ]
};

And here is foo.js:

console.log(1);

Both this.warn and this.error are undefined, but they should be defined.

Activity

  1. olsonpm commented on Jan 24, 2017

    @olsonpm
    Contributor

    per the wiki

    Inside a transform function, you can use this.warn(warning[, pos]) to provide feedback in a standard form.

    transformBundle doesn't have a note about this.warn

  2. Pauan commented on Jan 24, 2017

    @Pauan
    ContributorAuthor

    @olsonpm I am aware. I am requesting that it be added to transformBundle as well.

  3. olsonpm commented on Jan 24, 2017

    @olsonpm
    Contributor

    Ah I misunderstood

  4. olsonpm commented on Jan 27, 2017

    @olsonpm
    Contributor

    Btw - I just came across this issue in my plugin (wanted this.warn inside the resolveId function). I looked at the warn code in rollup and it's very coupled to the transform function. Because of that, the quickest solution is to just provide your own onwarn plugin option.

    It's a workaround, not a solution - but it worksaround well enough for me

  5. guybedford commented on Jun 6, 2018

    @guybedford
    Contributor

    These are now available for plugins in #2208.

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

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions