fraktalio / fmodel-ts

Functional Domain Modeling with Typescript

Home Page:https://fraktalio.com/fmodel-ts

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Storybook complains about class properties with the current build target

mahulst opened this issue · comments

  • I'm submitting a ...
    [ ] bug report
    [ ] feature request
    [x] question about the decisions made in the repository
    [ ] question about how to use this project

  • Summary
    When using this dependency in a project with storybook it will complain about the class properties defined in this module's build.
    Node modules are preferably not processed by the babel loader because it slows down the startup time.

  • Other information
    Stacktrace:

ERROR in <snip>/common/temp/node_modules/.pnpm/@fraktalio+fmodel-ts@1.1.0/node_modules/@fraktalio/fmodel-ts/build/module/lib/domain/saga.js 38:9                                 
Module parse failed: Unexpected token (38:9)                                                                                                                                                                     
You may need an appropriate loader to handle this file type, currently no loaders are configured to process this file. See https://webpack.js.org/concepts#loaders                                               
|  */                                                                                                                                                                                                            
| export class Saga {                                                                                                                                                                                            
>     react;                                                                                                                                                                                                     
|     /**                                                                                                                                                                                                        
|      * @constructor Creates `Saga`                                                                                                                                                                             
 @ <snip>/common/temp/node_modules/.pnpm/@fraktalio+fmodel-ts@1.1.0/node_modules/@fraktalio/fmodel-ts/build/module/index.js 15:0-34 15:0-34                                      
 @ ../remarks/dist/commonjs/domain/list-remark.js                                                                                                                                                                
 @ ../remarks/dist/commonjs/index.js                                                                                                                                                                             
 @ ../component-lib/src/components/Remarks/ListRemarkDetail.tsx                                                                                                                                                  
 @ ../component-lib/src/components/Remarks/index.tsx                                                                                                                                                             
 @ ../component-lib/src/index.tsx                                                                                                                                                                                
 @ ./.storybook/preview.tsx                                                                                                                                                                                      
 @ ./.storybook/preview.tsx-generated-config-entry.js       

It looks like it is picking up the module build that is specified with build target "ESNext" in the tsconfig.module.json or this project.

I tried three things that seem to fix the issue:

  1. Change the target to "ES2020" in tsconfig.module.js.
  2. Do not expose a "module": "build/module/index.js" in the package.json
  3. Change storybook's webpack config to also transpile node_modules.

Both of these solutions are done in this project.
Would you accept either 1 or 2 as a PR?
Or do you have a better solution?

@mahulst thanks for submitting the issue!

I prefer option 1 as a PR.