stencil icon indicating copy to clipboard operation
stencil copied to clipboard

bug: `extTransformsPlugin` is outputting collections css files

Open George-Payne opened this issue 2 years ago • 1 comments

Prerequisites

Stencil Version

v2.14.2 😃

Current Behavior

When building a dist output with a collection dependency, the dependencies css files will be outputted as part of the collection output, however, they appear further up the file tree due to their relative file paths. These css files aren't needed needed for the collection.

image

Expected Behavior

The css files aren't outputted.

Steps to Reproduce

Clone https://github.com/George-Payne/extTransformsPlugin-bug-reproduction

yarn is being used for workspaces, npm wont work

  1. yarn
  2. yarn build

Observe:

collectionconsumer
├── dist
│   ├── cjs
│   ├── collection
│   ├── collectionconsumer
│   ├── esm
│   ├── index.cjs.js
│   ├── index.js
│   ├── loader
│   └── types
├── externalcollection    <------------- This folder should not be outputted
│   └── dist
│       └── collection
│           └── components
│               └── ext-component
│                   └── ext-component.css
├── node_modules
├── package.json
├── src
├── stencil.config.ts
└── tsconfig.json

Code Reproduction URL

https://github.com/George-Payne/extTransformsPlugin-bug-reproduction

Additional Information

No response

George-Payne avatar Mar 28 '22 16:03 George-Payne

Any updates on this we are facing the same issue?

duncanhunter avatar Jun 06 '22 12:06 duncanhunter

Have you found any way to solve this locally? I'm facing the same issue.

DennisJamin avatar Dec 16 '22 09:12 DennisJamin

Have you found any way to solve this locally?

If you're using yarn 3+, you can apply the patch (#3306) directly to your the dependency:

https://yarnpkg.com/features/protocols/#patch

Run the patch command:

 yarn patch @stencil/core
➤ YN0000: Package @stencil/core@npm:2.17.4 got extracted with success!
➤ YN0000: You can now edit the following folder: /tmp/xfs-dde1e6ea/user
➤ YN0000: Once you are done run yarn patch-commit /tmp/xfs-dde1e6ea/user and Yarn will store a patchfile based on your changes.
➤ YN0000: Done in 0s 166ms

Open up the generated folder:

code /tmp/xfs-dde1e6ea/user

Modify compiler/stencil.js

-          const moduleFile = cmp && compilerCtx.moduleMap.get(cmp.sourceFilePath);
+          const moduleFile = cmp && !cmp.isCollectionDependency && compilerCtx.moduleMap.get(cmp.sourceFilePath);

Save the file, then apply the patch:

yarn patch-commit /tmp/xfs-dde1e6ea/user --save

I was originally doing this, but you need to do it every time you update stencil, and I decided it wasn't worth it, and to just add the folder to .gitignore and live with it.

George-Payne avatar Dec 16 '22 10:12 George-Payne

Thanks for your thorough writeup!

I'm using NPM and am considering the patch-package approach, but I indeed foresee the issues with updating Stencil. I'm surprised this isn't a more widespread issue.

DennisJamin avatar Dec 16 '22 10:12 DennisJamin