weiran-zsd / dts-cli

Zero-config CLI for TypeScript package development
MIT License
442 stars 23 forks source link

Typescript version of the config file (dts.config.ts) throws an error when running build #207

Open lukasbals opened 12 months ago

lukasbals commented 12 months ago

Current Behavior

When I use a dts.config.ts (Typescript version of the config file) with the following contents (same as in the example in the readme):

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.
  },
});

I get the following error when running npm run build (dts build):

Error: Cannot find module 'dts-cli'
Require stack:
- /Users/lukasbals/treely/strapi-slices/dts.config.ts
- /Users/lukasbals/treely/strapi-slices/node_modules/dts-cli/dist/createBuildConfigs.js
- /Users/lukasbals/treely/strapi-slices/node_modules/dts-cli/dist/index.js

    at Function.Module._resolveFilename (node:internal/modules/cjs/loader:1077:15)
    at Function.Module._resolveFilename.sharedData.moduleResolveFilenameHook.installedValue [as _resolveFilename] (/Users/lukasbals/treely/strapi-slices/node_modules/@cspotcode/source-map-support/source-map-support.js:811:30)
    at Function.Module._load (node:internal/modules/cjs/loader:922:27)
    at Module.require (node:internal/modules/cjs/loader:1143:19)
    at require (node:internal/modules/cjs/helpers:119:18)
    at Object.<anonymous> (/Users/lukasbals/treely/strapi-slices/dts.config.ts:1:1)
    at Module._compile (node:internal/modules/cjs/loader:1256:14)
    at Module.m._compile (/Users/lukasbals/treely/strapi-slices/node_modules/ts-node/src/index.ts:1618:23)
    at Module._extensions..js (node:internal/modules/cjs/loader:1310:10)
    at Object.require.extensions.<computed> [as .ts] (/Users/lukasbals/treely/strapi-slices/node_modules/ts-node/src/index.ts:1621:12)

Expected behavior

The build starts.

Suggested solution(s)

-

Additional context

-

Your environment

  System:
    OS: macOS 14.1.1
    CPU: (10) arm64 Apple M1 Pro
    Memory: 64.41 MB / 16.00 GB
    Shell: 5.9 - /bin/zsh
  Binaries:
    Node: 18.18.2 - ~/.nvm/versions/node/v18.18.2/bin/node
    Yarn: 1.22.19 - /opt/homebrew/bin/yarn
    npm: 10.2.4 - ~/treely/strapi-slices/node_modules/.bin/npm
  Browsers:
    Chrome: 119.0.6045.199
    Safari: 17.1
  npmPackages:
    dts-cli: ^2.0.3 => 2.0.3
    typescript: ^5.3.2 => 5.3.2
  npmGlobalPackages:
    dts-cli: 2.0.3