question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Include CSS from lerna module in preact

See original GitHub issue

Do you want to request a feature or report a bug?

Bug, likely a user configuration error thought.

What is the current behaviour?

Error is thrown during compilation when running preact watch

ERROR in /workspaces/preact-apps/packages/common/lib/components/Select.tsx(3,19): TS2307: Cannot find module ‘./select.css’ or its corresponding type declarations.

If the current behaviour is a bug, please provide the steps to reproduce.

The typescript app has been set up using the preact-cli create command. The app uses some shared code that is referenced through lerna in node_modules. I’ve already been using the shared code in another preact project that is using a custom configuration (webpack).

Folder structure:

├── packages
│   ├── common
│   │   └── components
│   │   │   ├── select.css
│   │   │   └── Select.tsx
│   ├── preact-cli-app
│   └── preact-webpack-app
└── lerna.json

preact-webpack-app uses the Select component. It runs and builds without issues.

Gists:

The css-loader options for preact-cli-app are:

{
  modules: { localIdentName: '[local]__[hash:base64:5]' },
  importLoaders: 1,
  sourceMap: true
}

I’m including the common module in the css rules

    config.module.rules[4].include =  [
      path.resolve(__dirname, 'src', 'routes'),
      path.resolve(__dirname, 'src', 'components'),
      path.resolve(__dirname, 'node_modules', 'common')
    ];
    config.module.rules[5].exclude = [
      path.resolve(__dirname, 'src', 'routes'),
      path.resolve(__dirname, 'src', 'components'),
      path.resolve(__dirname, 'node_modules', 'common')
    ];

What is the expected behaviour?

Typescript to build components in the common module without errors.

If this is a feature request, what is motivation or use case for changing the behaviour?

N/A

Please mention other relevant information.

I’ve taken a look at similar issues in this repository (#1368, #1475, #1218, #522) and on stackoverflow. Unfortunately, none have helped thus far.

Please paste the results of preact info here.

Environment Info:
  System:
    OS: macOS 11.0.1
    CPU: (16) x64 Intel(R) Core(TM) i9-9880H CPU @ 2.30GHz
  Binaries:
    Node: 12.16.1 - /usr/local/bin/node
    npm: 6.14.8 - ~/.npm-global/bin/npm
  Browsers:
    Chrome: 87.0.4280.88
    Firefox: 83.0
    Safari: 14.0.1
  npmPackages:
    preact: 10.5.5 => 10.5.5
    preact-cli: ^3.0.0 => 3.0.3
    preact-render-to-string: ^5.1.4 => 5.1.12
    preact-router: ^3.2.1 => 3.2.1
  npmGlobalPackages:
    preact-cli: 3.0.3

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Comments:5 (4 by maintainers)

github_iconTop GitHub Comments

1reaction
rschristiancommented, Dec 10, 2020

@bhr Sorry, got busy right after work and could only look now.

Your issue is that your declaration file (typings.d.ts) isn’t actually included in your tsconfig.json. Simply add it to the include array and you should be good to go.

After making that small edit the project could then build. TS just didn’t know about the existence of that file is all.

1reaction
rschristiancommented, Dec 9, 2020

Whoops, sorry, didn’t realize .d.ts files were limited like that. I’ll take a look later. Repo helps a lot.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Can't add local package in a monorepo lerna project - Support
I have a monorepo that uses yarn workspaces + lerna. In my “frontend” package, I want to add the “tsdx-test” which is another...
Read more >
Creating a React Component Library using Rollup, Typescript ...
If you don't want to use Sass, I'll also be showing you how to use CSS Modules, LESS, or Stylus to build your...
Read more >
How do I import an external CSS Stylesheet in fresh + preact?
1 Answer 1 · add a file someCssStylesheet.css to the /static folder · pick a route/page that you want the stylesheet to apply...
Read more >
@emotion/utils | Yarn - Package Manager
v10.0.0 (2018-10-27). Emotion 10 is a big change that we're really excited about with improvements to the css prop, a Global component for...
Read more >
How to use the customize-cra.useEslintRc function in ... - Snyk
coveragePathIgnorePatterns = ['/dist/']; // we tell Jest to import the @quid packages from their ... moduleNameMapper = lernaAlias.jest(); return config; },.
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found