Skip to content

Incorrect context provided for bundler plugin transforms #1707

@DesignByOnyx

Description

@DesignByOnyx

Stencil version:

 @stencil/core@1.0.2

I'm submitting a:

[x] bug report
[ ] feature request
[ ] support request => Please do not submit support requests here, use one of these channels: https://stencil-worldwide.herokuapp.com/ or https://forum.ionicframework.com/

Current behavior:
According to the Stencil docs the stencil bundler uses rollup under the hood and we should be able to provide our own rollup plugins. However, the "transform" hook is not called with the proper rollup plugin context. This is not only breaking the ability for me to create my own plugin, but it also breaks community plugins which reference this.xxxx inside the transform method.

Expected behavior:
I would expect that my rollup plugin transform hook be called with the correct rollup plugin context. See the rollup plugin context docs.

Steps to reproduce:
You can use the existing @stencil/postcss plugin and try calling this.addWatchFile() from inside the transform function.

Other information:
I am willing and eager to fix this if you can provide some insight. I have been digging through the compiler code for hours and cannot figure out the abstraction you have created around rollup. The existing buildCtx and compilerCtx do not contain the rollup plugin context, and I cannot figure out how to inject it.

UPDATE: the primary issue I am running into is the fact that @import'd files are not being watched (using either @stencil/postcss or @stencil/sass). This could be easily fixed if we could call this.addWatchFile from inside the transform function.

Update 2022.04.04

The following information is from #3303:

Steps to Reproduce

See the linked fork: https://github.com/ionic-team/stencil-sass/compare/master...DesignByOnyx:rwheale/1707-rollup-context-bug?expand=1

To get you there quicker:

git clone https://github.com/DesignByOnyx/stencil-sass.git
cd stencil-sass
npm i
npm run build
npm test

Code Reproduction URL

https://github.com/ionic-team/stencil-sass/compare/master...DesignByOnyx:rwheale/1707-rollup-context-bug?expand=1

Metadata

Metadata

Assignees

No one assigned

    Labels

    Feature: Want this? Upvote it!This PR or Issue may be a great consideration for a future idea.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions