forumone / gesso

Gesso Drupal theme
66 stars 13 forks source link

[841] Allow stories to be imported for side effects #842

Closed kmonahan closed 3 months ago

kmonahan commented 3 months ago

Closes #841 . Explicitly marks .stories.jsx files as having side effects, so they won't be tree-shaken. That fixed the issue, but I went ahead and also updated the import method for stories that are imported just for their assets, since those should be using side effect imports anyway.

coreylafferty commented 3 months ago

@kmonahan I'm getting a 'Drupal not defined' error after compiling all this. I don't think this is related, but do a pull on this branch b/c I updated it with the latest changes from 5.x-RC just in case there's something in there that caused this.

Untitled

kmonahan commented 3 months ago

I'll take a look. Not sure at first glance why it would be related to the work here, but one never knows.

kmonahan commented 3 months ago

Hm, still not totally sure why that error was appearing, but it seems like Storybook was no longer importing files with side effects that weren't called out in package.json, even though they were imported correctly. Maybe the assumption is that if sideEffects exists in package.json and a file is not listed in it, the file can be removed if doesn't appear to be used. (Interestingly, when I tested this originally, I was testing using ddev gesso build, since I thought tree-shaking only occurred in production build. But that seemed to be working yesterday, while when I fired up ddev gesso watch, I saw the error you were getting. So I'm still a bit puzzled.)

I tried a different approach and added sideEffects to the rule in the webpack config rather than to package.json, and that seems to be working better.