Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Scaffolded project does not build out of the box with README customization recommendations #211

Closed
SirSKillz opened this issue Feb 23, 2024 · 1 comment

Comments

@SirSKillz
Copy link

SirSKillz commented Feb 23, 2024

Current Behavior

After using npx dts-cli create test[1-3] with all cases (basic, react, react with storybook), I noticed that react with storybook does not build at all out of the box (#212), and none of them will build after adding the dts.config.ts file from the configuration section with this error:

Error: Cannot find module 'dts-cli'
Require stack:
- C:\Users\_\repos\test1\dts.config.ts
- C:\Users\_\repos\test1\node_modules\dts-cli\dist\createBuildConfigs.js
- C:\Users\_\repos\test1\node_modules\dts-cli\dist\index.js

    at Function.Module._resolveFilename (node:internal/modules/cjs/loader:1048:15)
    at Function.Module._resolveFilename.sharedData.moduleResolveFilenameHook.installedValue [as _resolveFilename] (C:\Users\_\repos\test1\node_modules\@cspotcode\source-map-support\source-map-support.js:811:30)
    at Function.Module._load (node:internal/modules/cjs/loader:901:27)
    at Module.require (node:internal/modules/cjs/loader:1115:19)
    at require (node:internal/modules/helpers:130:18)
    at Object.<anonymous> (C:\Users\_\repos\test1\dts.config.ts:1:1)
    at Module._compile (node:internal/modules/cjs/loader:1241:14)
    at Module.m._compile (C:\Users\_\repos\test1\node_modules\ts-node\src\index.ts:1618:23)
    at Module._extensions..js (node:internal/modules/cjs/loader:1295:10)
    at Object.require.extensions.<computed> [as .ts] (C:\Users\_\repos\test1\node_modules\ts-node\src\index.ts:1621:12)

Here is the original dts.config.ts file:

import { defineConfig } from 'dts-cli';

export default defineConfig({
  // This function will run for each entry/format/env combination
  rollup: (config, options) => {
    return config; // always return a config.
  },
});

After adjusting the dts.config.ts file from export default defineConfig({...}) to module.exports = defineConfig({...}), the same error occurs. Finally, changing the syntax to module.exports = {...} allows all 3 to build properly (react with storybook needed some other changes in tsconfig.json first [#212]).

Expected behavior

Ideally: Any of these methods of exporting should work correctly
At least: It should be made clear that only module.exports = {...} will function

Suggested solution(s)

Presumably this is an issue with the code that merges these files, or maybe defineConfig itself. I assume adjusting one of these would allow it to handle different export methods

Additional context

None

Your environment

System:
    OS: Windows 10 10.0.19045
    CPU: (24) x64 AMD Ryzen 9 5900X 12-Core Processor
    Memory: 18.75 GB / 31.91 GB
  Binaries:
    Node: 20.9.0 - C:\Program Files\nodejs\node.EXE
    npm: 10.1.0 - C:\Program Files\nodejs\npm.CMD
  Browsers:
    Chrome: 121.0.6167.187
    Edge: Chromium (121.0.2277.128)
    Internet Explorer: 11.0.19041.3636
  npmPackages:
    dts-cli: ^2.0.4 => 2.0.4
    typescript: ^5.3.3 => 5.3.3
@OlegWock
Copy link

Adding

"main": "./dist/index.js",

into node_modules/dts-cli/package.json (either by maintainer or by using patch-package) should solve this and #207

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants