Coder Social home page Coder Social logo

weiran-zsd / dts-cli Goto Github PK

View Code? Open in Web Editor NEW

This project forked from jaredpalmer/tsdx

439.0 439.0 23.0 11.27 MB

Zero-config CLI for TypeScript package development

License: MIT License

JavaScript 28.28% TypeScript 70.74% HTML 0.54% CSS 0.33% Shell 0.12%
babel react rollup tsdx typescript

dts-cli's People

Contributors

agilgur5 avatar aladdin-add avatar aleclarson avatar allcontributors[bot] avatar arthurdenner avatar audiolion avatar dependabot[bot] avatar fredyc avatar goznauk avatar greenkeeper[bot] avatar hedgerh avatar igordanchenko avatar jakegavin avatar jamesgeorge007 avatar jaredpalmer avatar kylemh avatar leonardodino avatar lookfirst avatar ludofischer avatar mfolnovic avatar n3tr avatar natemoo-re avatar nstfkc avatar pravi avatar renovate[bot] avatar sadsa avatar sam-kvale-sap avatar swyxio avatar topplethenun avatar yordis avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar

dts-cli's Issues

Error: Command failed with exit code 1

Current Behavior

❯ npx dts-cli create bld
  ____    _____   ____  
 |  _ \  |_   _| / ___| 
 | | | |   | |   \___ \ 
 | |_| |   | |    ___) |
 |____/    |_|   |____/ 
                        
✔ Choose a template · basic
✔ Created bld
✖ Failed to install dependencies
Error: Command failed with exit code 1: yarn add @size-limit/preset-small-lib @tsconfig/recommended dts-cli husky size-limit tslib typescript --dev
warning dts-cli > rollup-plugin-sourcemaps > [email protected]: See https://github.com/lydell/source-map-resolve#deprecated
error @typescript-eslint/[email protected]: The engine "node" is incompatible with this module. Expected version "^12.22.0 || ^14.17.0 || >=16.0.0". Got "14.15.5"
error Found incompatible module.
yarn add v1.22.17
info No lockfile found.
[1/5] Validating package.json...
[2/5] Resolving packages...
[3/5] Fetching packages...
info Visit https://yarnpkg.com/en/docs/cli/add for documentation about this command.

Expected behavior

No error

Suggested solution(s)

Probably copy from tsdx some configurations.

Additional context

Your environment

npx: installed 1 in 1.234s

  System:
    OS: macOS 11.5.2
    CPU: (12) x64 Intel(R) Core(TM) i7-8850H CPU @ 2.60GHz
    Memory: 399.97 MB / 16.00 GB
    Shell: 5.8 - /bin/zsh
  Binaries:
    Node: 14.15.5 - ~/.nvm/versions/node/v14.15.5/bin/node
    Yarn: 1.22.17 - ~/.nvm/versions/node/v14.15.5/bin/yarn
    npm: 6.14.16 - ~/.nvm/versions/node/v14.15.5/bin/npm
  Browsers:
    Brave Browser: 86.1.16.75
    Chrome: 100.0.4896.88
    Chrome Canary: 103.0.5006.0
    Firefox: 97.0.1
    Safari: 14.1.2

How can I add some code to run before the require statement in cli.js ?

Current Behavior

I'm trying to run some code at the top of a file, before anything else runs, before imports even. But the problem is that the generated files always hoist imports up, which causes a problem for me.

What I want to do, is check if a dependency exist before trying to import it, so that I can let the user install first it.

Expected behavior

Imports shouldn't be hoisted based on my little knowledge.

Suggested solution(s)

There should be a way to inject some code in the cli index before the require statement.

Your environment

  System:
    OS: Linux 5.4 Ubuntu 18.04.6 LTS (Bionic Beaver)
    CPU: (4) x64 Intel(R) Core(TM) i5-4310M CPU @ 2.70GHz
    Memory: 1.06 GB / 11.60 GB
    Container: Yes
    Shell: 4.4.20 - /bin/bash
  Binaries:
    Node: 14.19.1 - ~/.nvm/versions/node/v14.19.1/bin/node
    npm: 6.14.16 - ~/.nvm/versions/node/v14.19.1/bin/npm
  Browsers:
    Chrome: 101.0.4951.41
    Firefox: 99.0
  npmPackages:
    dts-cli: ^1.1.5 => 1.5.1 
    typescript: ^4.5.4 => 4.6.4 

Problem with "paths" in tsconfig configuration

Hello. Thank for the awesome library.
I am currently using paths in my tsconfig as I have a very complex structure folder. The project itself compiles perfectly but when it's bundled I get imports error (I am using the example folder to test the project).

Error: The following dependencies are imported but could not be resolved:

  store (imported by /Users/michelecocuccio/Documents/Michele/Projects/Simple React Lightbox/NEW/srl/simple-react-lightbox/dist/simple-react-lightbox.esm.js)
  store/reducers/srlSlice (imported by /Users/michelecocuccio/Documents/Michele/Projects/Simple React Lightbox/NEW/srl/simple-react-lightbox/dist/simple-react-lightbox.esm.js)
  utils (imported by /Users/michelecocuccio/Documents/Michele/Projects/Simple React Lightbox/NEW/srl/simple-react-lightbox/dist/simple-react-lightbox.esm.js)
  hooks (imported by /Users/michelecocuccio/Documents/Michele/Projects/Simple React Lightbox/NEW/srl/simple-react-lightbox/dist/simple-react-lightbox.esm.js)
  styledComponents/SRLLightboxSC (imported by /Users/michelecocuccio/Documents/Michele/Projects/Simple React Lightbox/NEW/srl/simple-react-lightbox/dist/simple-react-lightbox.esm.js)
  SRLComponents/SRLContainer (imported by /Users/michelecocuccio/Documents/Michele/Projects/Simple React Lightbox/NEW/srl/simple-react-lightbox/dist/simple-react-lightbox.esm.js)

Is there a way to make sure the paths are compiled correctly when the project is bundled?

Paths in tsconfig
Project structure
Dist folder

Your environment

  System:
    OS: macOS 12.0.1
    CPU: (8) x64 Intel(R) Core(TM) i7-7820HQ CPU @ 2.90GHz
    Memory: 39.71 MB / 16.00 GB
    Shell: 5.8 - /bin/zsh
  Binaries:
    Node: 16.13.0 - /usr/local/bin/node
    Yarn: 1.22.15 - ~/.yarn/bin/yarn
    npm: 8.1.0 - /usr/local/bin/npm
  Browsers:
    Chrome: 97.0.4692.71
    Firefox: 95.0.2
    Safari: 15.1
  npmPackages:
    dts-cli: ^1.1.5 => 1.1.5
    typescript: ^4.5.4 => 4.5.4

Publishing fork under a new name

First let me thank you for your amazing work on this fork.

It would be nice that all of this effort gets more recognition. It's actually not that straightforward to land on this repository.

Have you considered publishing this package under a new name?

Regards,

Rollup type definitions

Current Behavior

TypeScript compiler outputs all type definitions into the dist folder regardless of whether they are relevant to the components exported from the library. Even dead code that doesn't make its way into the final .js rollup still produces type definitions in the dist folder. Unless you take some extra steps, all those .d.ts files end up in your npm package.

Let's assume the following project structure:

src
  foo
    foo.tsx
  bar
    bar.tsx
  ComponentA.tsx
  ComponentB.tsx
  index.tsx

dts-cli build produces the following dist output:

dist
  foo
    foo.d.ts
  bar
    bar.d.ts
  ComponentA.d.ts
  ComponentB.d.ts
  foo-bar.cjs.development.js
  foo-bar.cjs.production.min.js
  foo-bar.esm.js
  index.d.ts
  index.js

Desired Behavior

  1. Produce only one .d.ts file - index.d.ts
  2. Tree-shake all unused type definitions.

so that the final output looks like the one below:

dist
  foo-bar.cjs.development.js
  foo-bar.cjs.production.min.js
  foo-bar.esm.js
  index.d.ts
  index.js

Suggested Solution

I achieved the desired goal with rollup-plugin-dts, but I didn't find an elegant way to plug into the build pipeline to execute a separate rollup build after all rollups are done. I ended up with the following patch package:

diff --git a/node_modules/dts-cli/dist/index.js b/node_modules/dts-cli/dist/index.js
index d5d2644..6285cd8 100755
--- a/node_modules/dts-cli/dist/index.js
+++ b/node_modules/dts-cli/dist/index.js
@@ -34,6 +34,8 @@ const utils_2 = require("./templates/utils");
 const deprecated = (0, tslib_1.__importStar)(require("./deprecated"));
 const sort_package_json_1 = (0, tslib_1.__importDefault)(require("sort-package-json"));
 const pkg = require('../package.json');
+const dts = require('rollup-plugin-dts').default;
+const del = require('rollup-plugin-delete');
 const prog = (0, sade_1.default)('dts');
 let appPackageJson;
 try {
@@ -60,6 +62,18 @@ async function jsOrTs(filename) {
                 : '.js';
     return (0, utils_1.resolveApp)(`${filename}${extension}`);
 }
+const rollupTypesConfig = {
+        input: "dist/types/index.d.ts",
+        output: { file: "dist/index.d.ts", format: "es" },
+        plugins: [
+            dts(),
+            del({ hook: "buildEnd", targets: "dist/types" })
+        ]
+    };
+async function rollupTypes() {
+    const bundle = await (0, rollup_1.rollup)(rollupTypesConfig);
+    await bundle.write(rollupTypesConfig.output);
+}
 async function getInputs(entries, source) {
     return (0, jpjs_1.concatAllArray)([]
         .concat(entries && entries.length
@@ -261,6 +275,7 @@ prog
 `);
             try {
                 await deprecated.moveTypes();
+                await rollupTypes();
                 if (firstTime && opts.onFirstSuccess) {
                     firstTime = false;
                     run(opts.onFirstSuccess);
@@ -314,6 +329,9 @@ prog
         })
             .then(async () => {
             await deprecated.moveTypes();
+        })
+            .then(async () => {
+            await rollupTypes();
         });
         logger(promise, 'Building modules');
         await promise;

I'm curious if there is a more straightforward approach that I simply overlooked. If not, would you be interested in adding this as a feature to dts-cli behind a feature flag? I'll be happy to contribute a more generic solution.

Who does this impact? Who is this for?

I'm assuming this can be useful for most developers working on TypeScript libraries that roll up all their code into a single file without preserving the directory structure.

Describe alternatives you've considered

There are some alternative options (i.e. api-extractor) that I haven't explored closely since rollup-plugin-dts option appears to fit more naturally into dts-api pipeline.

Switch to @rollup/plugin-typescript from rollup-plugin-typescript2

Current Behavior

Currently rollup-plugin-typescript2 is used

Desired Behavior

typanion and clipanion recently moved to @rollup/plugin-typescript arcanis/typanion#8

as it is maintained by rollup community directly has better chance of long term maintenance.

Suggested Solution

Update dependency to @rollup/plugin-typescript

Who does this impact? Who is this for?

Switching to better maintained dependencies is always a big win for long term

Describe alternatives you've considered

Additional context

It'd help in reducing maintenance in debian, we already have @rollup/plugin-typescript and it'd be nice if we can avoid maintaining rollup-plugin-typescript2 as well.

node v17 compat: Error loading `tslib` helper library.

Current Behavior

Error loading `tslib` helper library.
/Users/weiran/repo/dian/tsdx/node_modules/rollup-plugin-typescript2/dist/rollup-plugin-typescript2.cjs.js:25177
    throw e;
    ^

Error [ERR_PACKAGE_PATH_NOT_EXPORTED]: Package subpath './package.json' is not defined by "exports" in /Users/weiran/repo/dian/tsdx/node_modules/rollup-plugin-typescript2/node_modules/tslib/package.json

Expected behavior

Suggested solution(s)

Additional context

Your environment

  System:
    OS: macOS 12.0
    CPU: (8) x64 Intel(R) Core(TM) i7-1068NG7 CPU @ 2.30GHz
    Memory: 703.07 MB / 32.00 GB
    Shell: 5.8 - /bin/zsh
  Binaries:
    Node: 17.0.0 - /usr/local/bin/node
    Yarn: 1.22.10 - ~/.npm-global/bin/yarn
    npm: 8.1.0 - ~/.npm-global/bin/npm
    Watchman: 20200920.192359.0 - /usr/local/bin/watchman
  Browsers:
    Brave Browser: 83.1.10.93
    Chrome: 94.0.4606.81
    Edge: 94.0.992.50
    Safari: 15.1
  npmGlobalPackages:
    dts-cli: 0.19.2
    typescript: 4.4.2

Command `npx dts-cli create mylib` fails because of Rollup module incompatibility with tsconfig.json

Current Behavior

Running the npx dts-cli create mylib command to create a new library fails because tsconfig.json contains module options incompatible with Rollup.

npx dts-cli create mylib
  ____    _____   ____  
 |  _ \  |_   _| / ___| 
 | | | |   | |   \___ \ 
 | |_| |   | |    ___) |
 |____/    |_|   |____/ 
                        
✔ Choose a template · basic
✔ Created mylib
✖ Failed to install dependencies
Error: Command failed with exit code 1: yarn add @size-limit/preset-small-lib @tsconfig/recommended dts-cli husky size-limit tslib typescript --dev
warning dts-cli > [email protected]: babel-eslint is now @babel/eslint-parser. This package will no longer receive updates.
Error: Incompatible tsconfig option. Module resolves to 'CommonJS'. This is incompatible with rollup, please use 'module: "ES2015"' or 'module: "ESNext"'.

    at checkTsConfig (/home/user/example/mylib/node_modules/rollup-plugin-typescript2/dist/rollup-plugin-typescript2.cjs.js:25125:15)
    at parseTsConfig (/home/user/example/mylib/node_modules/rollup-plugin-typescript2/dist/rollup-plugin-typescript2.cjs.js:25156:5)
    at Object.options (/home/user/example/mylib/node_modules/rollup-plugin-typescript2/dist/rollup-plugin-typescript2.cjs.js:30033:73)
    at /home/user/example/mylib/node_modules/rollup/dist/shared/rollup.js:23384:43
    at async /home/user/example/mylib/node_modules/rollup/dist/shared/rollup.js:23384:99
    at async getInputOptions (/home/user/example/mylib/node_modules/rollup/dist/shared/rollup.js:23377:61)
    at async rollupInternal (/home/user/example/mylib/node_modules/rollup/dist/shared/rollup.js:23324:72)
    at async /home/user/example/mylib/node_modules/dts-cli/dist/index.js:300:26
    at async Promise.all (index 2)

error Command failed with exit code 1.
yarn add v1.22.15
info No lockfile found.
[1/5] Validating package.json...
[2/5] Resolving packages...
[3/5] Fetching packages...
info [email protected]: The platform "linux" is incompatible with this module.
info "[email protected]" is an optional dependency and failed compatibility check. Excluding it from installation.
[4/5] Linking dependencies...
[5/5] Building fresh packages...
success Saved lockfile.
success Saved 564 new dependencies.
info Direct dependencies
├─ @size-limit/[email protected]
├─ @tsconfig/[email protected]
├─ [email protected]
├─ [email protected]
├─ [email protected]
├─ [email protected]
└─ [email protected]
info All dependencies
├─ @babel/[email protected]
├─ @babel/[email protected]
├─ @babel/[email protected]
├─ @babel/[email protected]
├─ @babel/[email protected]
├─ @babel/[email protected]
├─ @babel/[email protected]
├─ @babel/[email protected]
├─ @babel/[email protected]
├─ @babel/[email protected]
├─ @babel/[email protected]
├─ @babel/[email protected]
├─ @babel/[email protected]
├─ @babel/[email protected]
├─ @babel/[email protected]
├─ @babel/[email protected]
├─ @babel/[email protected]
├─ @babel/[email protected]
├─ @babel/[email protected]
├─ @babel/[email protected]
├─ @babel/[email protected]
├─ @babel/[email protected]
├─ @babel/[email protected]
├─ @babel/[email protected]
├─ @babel/[email protected]
├─ @babel/[email protected]
├─ @babel/[email protected]
├─ @babel/[email protected]
├─ @babel/[email protected]
├─ @babel/[email protected]
├─ @babel/[email protected]
├─ @babel/[email protected]
├─ @babel/[email protected]
├─ @babel/[email protected]
├─ @babel/[email protected]
├─ @babel/[email protected]
├─ @babel/[email protected]
├─ @babel/[email protected]
├─ @babel/[email protected]
├─ @babel/[email protected]
├─ @babel/[email protected]
├─ @babel/[email protected]
├─ @babel/[email protected]
├─ @babel/[email protected]
├─ @babel/[email protected]
├─ @babel/[email protected]
├─ @babel/[email protected]
├─ @babel/[email protected]
├─ @babel/[email protected]
├─ @babel/[email protected]
├─ @babel/[email protected]
├─ @babel/[email protected]
├─ @babel/[email protected]
├─ @babel/[email protected]
├─ @babel/[email protected]
├─ @babel/[email protected]
├─ @babel/[email protected]
├─ @babel/[email protected]
├─ @babel/[email protected]
├─ @babel/[email protected]
├─ @babel/[email protected]
├─ @babel/[email protected]
├─ @babel/[email protected]
├─ @babel/[email protected]
├─ @babel/[email protected]
├─ @babel/[email protected]
├─ @babel/[email protected]
├─ @babel/[email protected]
├─ @babel/[email protected]
├─ @babel/[email protected]
├─ @babel/[email protected]
├─ @babel/[email protected]
├─ @babel/[email protected]
├─ @bcoe/[email protected]
├─ @eslint/[email protected]
├─ @humanwhocodes/[email protected]
├─ @humanwhocodes/[email protected]
├─ @istanbuljs/[email protected]
├─ @jest/[email protected]
├─ @jest/[email protected]
├─ @jest/[email protected]
├─ @nodelib/[email protected]
├─ @nodelib/[email protected]
├─ @nodelib/[email protected]
├─ @rollup/[email protected]
├─ @rollup/[email protected]
├─ @rollup/[email protected]
├─ @rollup/[email protected]
├─ @rollup/[email protected]
├─ @rollup/[email protected]
├─ @sinonjs/[email protected]
├─ @sinonjs/[email protected]
├─ @size-limit/[email protected]
├─ @size-limit/[email protected]
├─ @size-limit/[email protected]
├─ @statoscope/[email protected]
├─ @statoscope/[email protected]
├─ @statoscope/[email protected]
├─ @statoscope/[email protected]
├─ @statoscope/[email protected]
├─ @statoscope/[email protected]
├─ @tootallnate/[email protected]
├─ @trysound/[email protected]
├─ @tsconfig/[email protected]
├─ @types/[email protected]
├─ @types/[email protected]
├─ @types/[email protected]
├─ @types/[email protected]
├─ @types/[email protected]
├─ @types/[email protected]
├─ @types/[email protected]
├─ @types/[email protected]
├─ @types/[email protected]
├─ @types/[email protected]
├─ @types/[email protected]
├─ @types/[email protected]
├─ @types/[email protected]
├─ @types/[email protected]
├─ @types/[email protected]
├─ @types/[email protected]
├─ @types/[email protected]
├─ @types/[email protected]
├─ @types/[email protected]
├─ @types/[email protected]
├─ @types/[email protected]
├─ @typescript-eslint/[email protected]
├─ @typescript-eslint/[email protected]
├─ @typescript-eslint/[email protected]
├─ @webassemblyjs/[email protected]
├─ @webassemblyjs/[email protected]
├─ @webassemblyjs/[email protected]
├─ @webassemblyjs/[email protected]
├─ @webassemblyjs/[email protected]
├─ @webassemblyjs/[email protected]
├─ @xtuc/[email protected]
├─ [email protected]
├─ [email protected]
├─ [email protected]
├─ [email protected]
├─ [email protected]
├─ [email protected]
├─ [email protected]
├─ [email protected]
├─ [email protected]
├─ [email protected]
├─ [email protected]
├─ [email protected]
├─ [email protected]
├─ [email protected]
├─ [email protected]
├─ [email protected]
├─ [email protected]
├─ [email protected]
├─ [email protected]
├─ [email protected]
├─ [email protected]
├─ [email protected]
├─ [email protected]
├─ [email protected]
├─ [email protected]
├─ [email protected]
├─ [email protected]
├─ [email protected]
├─ [email protected]
├─ [email protected]
├─ [email protected]
├─ [email protected]
├─ [email protected]
├─ [email protected]
├─ [email protected]
├─ [email protected]
├─ [email protected]
├─ [email protected]
├─ [email protected]
├─ [email protected]
├─ [email protected]
├─ [email protected]
├─ [email protected]
├─ [email protected]
├─ [email protected]
├─ [email protected]
├─ [email protected]
├─ [email protected]
├─ [email protected]
├─ [email protected]
├─ [email protected]
├─ [email protected]
├─ [email protected]
├─ [email protected]
├─ [email protected]
├─ [email protected]
├─ [email protected]
├─ [email protected]
├─ [email protected]
├─ [email protected]
├─ [email protected]
├─ [email protected]
├─ [email protected]
├─ [email protected]
├─ [email protected]
├─ [email protected]
├─ [email protected]
├─ [email protected]
├─ [email protected]
├─ [email protected]
├─ [email protected]
├─ [email protected]
├─ [email protected]
├─ [email protected]
├─ [email protected]
├─ [email protected]
├─ [email protected]
├─ [email protected]
├─ [email protected]
├─ [email protected]
├─ [email protected]
├─ [email protected]
├─ [email protected]
├─ [email protected]
├─ [email protected]
├─ [email protected]
├─ [email protected]
├─ [email protected]
├─ [email protected]
├─ [email protected]
├─ [email protected]
├─ [email protected]
├─ [email protected]
├─ [email protected]
├─ [email protected]
├─ [email protected]
├─ [email protected]
├─ [email protected]
├─ [email protected]
├─ [email protected]
├─ [email protected]
├─ [email protected]
├─ [email protected]
├─ [email protected]
├─ [email protected]
├─ [email protected]
├─ [email protected]
├─ [email protected]
├─ [email protected]
├─ [email protected]
├─ [email protected]
├─ [email protected]
├─ [email protected]
├─ [email protected]
├─ [email protected]
├─ [email protected]
├─ [email protected]
├─ [email protected]
├─ [email protected]
├─ [email protected]
├─ [email protected]
├─ [email protected]
├─ [email protected]
├─ [email protected]
├─ [email protected]
├─ [email protected]
├─ [email protected]
├─ [email protected]
├─ [email protected]
├─ [email protected]
├─ [email protected]
├─ [email protected]
├─ [email protected]
├─ [email protected]
├─ [email protected]
├─ [email protected]
├─ [email protected]
├─ [email protected]
├─ [email protected]
├─ [email protected]
├─ [email protected]
├─ [email protected]
├─ [email protected]
├─ [email protected]
├─ [email protected]
├─ [email protected]
├─ [email protected]
├─ [email protected]
├─ [email protected]
├─ [email protected]
├─ [email protected]
├─ [email protected]
├─ [email protected]
├─ [email protected]
├─ [email protected]
├─ [email protected]
├─ [email protected]
├─ [email protected]
├─ [email protected]
├─ [email protected]
├─ [email protected]
├─ [email protected]
├─ [email protected]
├─ [email protected]
├─ [email protected]
├─ [email protected]
├─ [email protected]
├─ [email protected]
├─ [email protected]
├─ [email protected]
├─ [email protected]
├─ [email protected]
├─ [email protected]
├─ [email protected]
├─ [email protected]
├─ [email protected]
├─ [email protected]
├─ [email protected]
├─ [email protected]
├─ [email protected]
├─ [email protected]
├─ [email protected]
├─ [email protected]
├─ [email protected]
├─ [email protected]
├─ [email protected]
├─ [email protected]
├─ [email protected]
├─ [email protected]
├─ [email protected]
├─ [email protected]
├─ [email protected]
├─ [email protected]
├─ [email protected]
├─ [email protected]
├─ [email protected]
├─ [email protected]
├─ [email protected]
├─ [email protected]
├─ [email protected]
├─ [email protected]
├─ [email protected]
├─ [email protected]
├─ [email protected]
├─ [email protected]
├─ [email protected]
├─ [email protected]
├─ [email protected]
├─ [email protected]
├─ [email protected]
├─ [email protected]
├─ [email protected]
├─ [email protected]
├─ [email protected]
├─ [email protected]
├─ [email protected]
├─ [email protected]
├─ [email protected]
├─ [email protected]
├─ [email protected]
├─ [email protected]
├─ [email protected]
├─ [email protected]
├─ [email protected]
├─ [email protected]
├─ [email protected]
├─ [email protected]
├─ [email protected]
├─ [email protected]
├─ [email protected]
├─ [email protected]
├─ [email protected]
├─ [email protected]
├─ [email protected]
├─ [email protected]
├─ [email protected]
├─ [email protected]
├─ [email protected]
├─ [email protected]
├─ [email protected]
├─ [email protected]
├─ [email protected]
├─ [email protected]
├─ [email protected]
├─ [email protected]
├─ [email protected]
├─ [email protected]
├─ [email protected]
├─ [email protected]
├─ [email protected]
├─ [email protected]
├─ [email protected]
├─ [email protected]
├─ [email protected]
├─ [email protected]
├─ [email protected]
├─ [email protected]
├─ [email protected]
├─ [email protected]
├─ [email protected]
├─ [email protected]
├─ [email protected]
├─ [email protected]
├─ [email protected]
├─ [email protected]
├─ [email protected]
├─ [email protected]
├─ [email protected]
├─ [email protected]
├─ [email protected]
├─ [email protected]
├─ [email protected]
├─ [email protected]
├─ [email protected]
├─ [email protected]
├─ [email protected]
├─ [email protected]
├─ [email protected]
├─ [email protected]
├─ [email protected]
├─ [email protected]
├─ [email protected]
├─ [email protected]
├─ [email protected]
├─ [email protected]
├─ [email protected]
├─ [email protected]
├─ [email protected]
├─ [email protected]
├─ [email protected]
├─ [email protected]
├─ [email protected]
├─ [email protected]
├─ [email protected]
├─ [email protected]
├─ [email protected]
├─ [email protected]
├─ [email protected]
├─ [email protected]
├─ [email protected]
├─ [email protected]
├─ [email protected]
├─ [email protected]
├─ [email protected]
├─ [email protected]
├─ [email protected]
├─ [email protected]
├─ [email protected]
├─ [email protected]
├─ [email protected]
├─ [email protected]
├─ [email protected]
├─ [email protected]
├─ [email protected]
├─ [email protected]
├─ [email protected]
├─ [email protected]
├─ [email protected]
├─ [email protected]
├─ [email protected]
├─ [email protected]
├─ [email protected]
├─ [email protected]
├─ [email protected]
├─ [email protected]
├─ [email protected]
├─ [email protected]
├─ [email protected]
├─ [email protected]
├─ [email protected]
├─ [email protected]
├─ [email protected]
├─ [email protected]
├─ [email protected]
├─ [email protected]
├─ [email protected]
├─ [email protected]
├─ [email protected]
├─ [email protected]
├─ [email protected]
├─ [email protected]
├─ [email protected]
├─ [email protected]
├─ [email protected]
├─ [email protected]
├─ [email protected]
├─ [email protected]
├─ [email protected]
├─ [email protected]
├─ [email protected]
├─ [email protected]
├─ [email protected]
├─ [email protected]
├─ [email protected]
├─ [email protected]
├─ [email protected]
├─ [email protected]
├─ [email protected]
├─ [email protected]
├─ [email protected]
├─ [email protected]
├─ [email protected]
├─ [email protected]
├─ [email protected]
├─ [email protected]
├─ [email protected]
├─ [email protected]
├─ [email protected]
├─ [email protected]
├─ [email protected]
├─ [email protected]
├─ [email protected]
├─ [email protected]
├─ [email protected]
├─ [email protected]
├─ [email protected]
├─ [email protected]
├─ [email protected]
├─ [email protected]
├─ [email protected]
├─ [email protected]
├─ [email protected]
├─ [email protected]
├─ [email protected]
├─ [email protected]
├─ [email protected]
├─ [email protected]
├─ [email protected]
├─ [email protected]
├─ [email protected]
├─ [email protected]
├─ [email protected]
├─ [email protected]
├─ [email protected]
├─ [email protected]
├─ [email protected]
├─ [email protected]
├─ [email protected]
├─ [email protected]
├─ [email protected]
├─ [email protected]
├─ [email protected]
├─ [email protected]
├─ [email protected]
├─ [email protected]
├─ [email protected]
├─ [email protected]
├─ [email protected]
├─ [email protected]
├─ [email protected]
├─ [email protected]
├─ [email protected]
├─ [email protected]
├─ [email protected]
├─ [email protected]
├─ [email protected]
├─ [email protected]
├─ [email protected]
├─ [email protected]
├─ [email protected]
├─ [email protected]
├─ [email protected]
├─ [email protected]
├─ [email protected]
├─ [email protected]
├─ [email protected]
├─ [email protected]
├─ [email protected]
└─ [email protected]
$ dts build
info Visit https://yarnpkg.com/en/docs/cli/add for documentation about this command.

    at makeError (/home/user/.npm/_npx/9780/lib/node_modules/dts-cli/node_modules/execa/lib/error.js:59:11)
    at handlePromise (/home/user/.npm/_npx/9780/lib/node_modules/dts-cli/node_modules/execa/index.js:114:26)
    at processTicksAndRejections (internal/process/task_queues.js:95:5)
    at async /home/user/.npm/_npx/9780/lib/node_modules/dts-cli/dist/index.js:169:9

Expected behavior

The command finishes the setup successfully.

Suggested solution(s)

Additional context

Your environment

  System:
    OS: Linux 5.11 Ubuntu 20.04.3 LTS (Focal Fossa)
    CPU: (8) x64 Intel(R) Core(TM) i7-6700HQ CPU @ 2.60GHz
    Memory: 6.99 GB / 15.54 GB
    Container: Yes
    Shell: 5.8 - /usr/bin/zsh
  Binaries:
    Node: 14.18.0 - /tmp/fnm_multishells/2688_1634980799404/bin/node
    Yarn: 1.22.15 - /tmp/fnm_multishells/2688_1634980799404/bin/yarn
    npm: 6.14.15 - /tmp/fnm_multishells/2688_1634980799404/bin/npm
  Browsers:
    Chrome: 94.0.4606.81
    Firefox: 93.0
  npmPackages:
    dts-cli: ^0.19.3 => 0.19.3 
    typescript: ^4.4.4 => 4.4.4 
  npmGlobalPackages:
    dts-cli: 0.19.3

Only first entry works when more than one is provided

Current Behavior

When running
dts build -i src/components/core/Badge/index.ts -i src/components/core/CssBaseline/index.ts
the second entry is ignored.

The dist/ folder only contains the bundle containing the Badge component in this case.

Expected behavior

I would expect having bundle files for CssBaseline too.

Suggested solution(s)

I don't have a clue 😂

Additional context

I just want to have one file for each component of a library of React components

Your environment

  System:
    OS: Linux 5.11 Ubuntu 20.04.3 LTS (Focal Fossa)
    CPU: (4) x64 Intel(R) Core(TM) i7-7560U CPU @ 2.40GHz
    Memory: 3.67 GB / 15.37 GB
    Container: Yes
    Shell: 5.0.17 - /bin/bash
  Binaries:
    Node: 14.17.5 - ~/.nvm/versions/node/v14.17.5/bin/node
    Yarn: 1.22.11 - ~/.nvm/versions/node/v14.17.5/bin/yarn
    npm: 7.21.0 - ~/.nvm/versions/node/v14.17.5/bin/npm
  Browsers:
    Brave Browser: 93.1.29.81
    Chrome: 93.0.4577.82
    Firefox: 92.0
  npmPackages:
    dts-cli: ^0.17.1 => 0.17.1 
    typescript: ^4.4.3 => 4.4.3 

CRA test in the subfolder is executed while running `npm run test`

I'm not sure it's a bug or miscofig.

Current Behavior

npm run test will run all the tests in the test folder as expect.
In the following cases, the sub folder test from other folder will be executed, and of cuz failed due to the environment setup differences.

steps to create the issues:

npx dts-cli create mylib

Go into the mylib, run CRA command to create a sub folder my-app, which will includes the default testing suites and a test case.

npx create-react-app my-app --template typescript

then run in root folder

npm run test

the test in test folder by dts-cli will pass but the test inside the my-app will run also and failed.

Expected behavior

Those tests should be ignored?

the new generated package.json looks strange

Current Behavior

{
  "version": "0.1.0",
  "license": "MIT",
  "main": "dist/index.js",
  "typings": "dist/index.d.ts",
  "files": [
    "dist",
    "src"
  ],
  "engines": {
    "node": ">=10"
  },
  "scripts": {
    "start": "dts watch",
    "build": "dts build",
    "test": "dts test",
    "lint": "dts lint",
    "prepare": "dts build",
    "size": "size-limit",
    "analyze": "size-limit --why"
  },
  "peerDependencies": {},
  "husky": {
    "hooks": {
      "pre-commit": "dts lint"
    }
  },
  "prettier": {
    "printWidth": 80,
    "semi": true,
    "singleQuote": true,
    "trailingComma": "es5"
  },
  "jest": {
    "testEnvironment": "node"
  },
  "name": "mylib",
  "author": "weiran",
  "module": "dist/mylib.esm.js",
  "size-limit": [
    {
      "path": "dist/mylib.cjs.production.min.js",
      "limit": "10 KB"
    },
    {
      "path": "dist/mylib.esm.js",
      "limit": "10 KB"
    }
  ],
  "devDependencies": {
    "@size-limit/preset-small-lib": "^7.0.3",
    "@tsconfig/recommended": "^1.0.1",
    "dts-cli": "^0.19.6",
    "husky": "^7.0.4",
    "size-limit": "^7.0.3",
    "tslib": "^2.3.1",
    "typescript": "^4.5.2"
  }
}

Expected behavior

a well-sorted package.json, using something like sort-package-json

Suggested solution(s)

Additional context

Your environment


declaration files missing

Current Behavior

no typescript declaration files (.d.ts) are output in the build

Expected behavior

declaration files should be included in build output

Suggested solution(s)

Not sure what the problem is

Additional context

I have a tsdx component library and I swapped it out with dts-cli but the build is missing declaration files. I didn't change anything except the scripts, package.json, and renamed tsdx.config.json to dts.config.json

Your environment

  System:
    OS: macOS 11.6
    CPU: (8) x64 Apple M1
    Memory: 26.42 MB / 16.00 GB
    Shell: 5.8 - /bin/zsh
  Binaries:
    Node: 16.13.2 - ~/n/bin/node
    Yarn: 1.22.17 - ~/n/bin/yarn
    npm: 8.1.2 - ~/n/bin/npm
  Browsers:
    Chrome: 97.0.4692.71
    Firefox: 95.0.2
    Safari: 15.0
  npmPackages:
    typescript: ^4.5.4 => 4.5.4 
  npmGlobalPackages:
    typescript: 4.3.5

Take esbuild into consideration

Current Behavior

Desired Behavior

tsdx has been around for quite some time. It does appear to me that the current (however undeniably awesome!) approach lost its momentum and there are other, newer tools (like mentioned in the title 'esbuild') we could wrap dts-cli around. Would love to hear your feedback

Suggested Solution

Who does this impact? Who is this for?

Probably most users

Describe alternatives you've considered

Additional context

Related: jaredpalmer#716

Aliases import in types definition isn't resolved on the build result

Current Behavior

I added absolute import aliases configuration in tsconfig.json

{
  "extends": "@tsconfig/create-react-app/tsconfig.json",
  "include": ["src", "types", "stories"],
  "compilerOptions": {
    "baseUrl": ".",
    "paths": {
      "@Components": ["src/Components"],
      "@Components/*": ["src/Components/*"]
    }
  } 
}

and using that aliases import in one of my interfaces file
image

but when running dts build which will bundle the component. the import still not updated to relative import and cause the types not detected and the component will lose the ability of the types since it's refer to the incorrect path.
image

Expected behavior

Expected behavior is that when build the app it will resolve all aliases import into relative import so that it refers to the correct path

Suggested solution(s)

None at the moment,

My temporary workaround is just to update all import to relative import. but it will be a mess if in the future i have deeper nested folder with ../../../ import

Additional context

Since this lib based on tsdx. I have tried many things from the github issue on tsdx library but nothing seems to work
jaredpalmer#91

What i have tried

Your environment

 System:
    OS: Windows 10 10.0.22000
    CPU: (16) x64 AMD Ryzen 7 5800H with Radeon Graphics
    Memory: 6.51 GB / 13.86 GB
  Binaries:
    Node: 16.13.2 - C:\Program Files\nodejs\node.EXE
    Yarn: 1.22.17 - ~\AppData\Roaming\npm\yarn.CMD
    npm: 8.1.2 - C:\Program Files\nodejs\npm.CMD
  Browsers:
    Edge: Spartan (44.22000.120.0), Chromium (98.0.1108.56)
    Internet Explorer: 11.0.22000.120
  npmPackages:
    dts-cli: ^1.4.0 => 1.4.0
    typescript: ^4.5.5 => 4.5.5

Does not support .cjs as file extension for config file.

Current Behavior

I am using type module in my package json for my code which breaks the require function that pulls in the config file

Expected behavior

Should pull in .cjs config file

Suggested solution(s)

Just needs to be able to support .cjs file import as an option instead of just .js and .ts

Your environment

 System:
    OS: macOS 12.5
    CPU: (12) x64 Intel(R) Core(TM) i7-9750H CPU @ 2.60GHz
    Memory: 164.73 MB / 16.00 GB
    Shell: 5.8.1 - /bin/zsh
  Binaries:
    Node: 16.14.0 - /usr/local/bin/node
    Yarn: 1.22.15 - /usr/local/bin/yarn
    npm: 8.3.1 - /usr/local/bin/npm
  Browsers:
    Chrome: 104.0.5112.79
    Safari: 15.6

DeprecationWarning: Use of deprecated folder mapping "./" in the "exports" field module resolution of the package

Current Behavior

(node:97280) [DEP0148] DeprecationWarning: Use of deprecated folder mapping "./" in the "exports" field module resolution of the package at /Users/weiran/.npm-global/lib/node_modules/dts-cli/node_modules/rollup-plugin-typescript2/node_modules/tslib/package.json.
Update this package.json to use a subpath pattern like "./*".
(Use `node --trace-deprecation ...` to show where the warning was created)

Expected behavior

Suggested solution(s)

Additional context

Your environment

  System:
    OS: macOS 12.0
    CPU: (8) x64 Intel(R) Core(TM) i7-1068NG7 CPU @ 2.30GHz
    Memory: 551.53 MB / 32.00 GB
    Shell: 5.8 - /bin/zsh
  Binaries:
    Node: 16.10.0 - /usr/local/bin/node
    Yarn: 3.0.0-rc.2.git.20210523.hash-664cc40d - ~/.npm-global/bin/yarn
    npm: 7.24.1 - ~/.npm-global/bin/npm
    Watchman: 20200920.192359.0 - /usr/local/bin/watchman
  Browsers:
    Brave Browser: 83.1.10.93
    Chrome: 94.0.4606.81
    Edge: 94.0.992.38
    Safari: 15.0
  npmGlobalPackages:
    dts-cli: 0.18.0
    typescript: 4.4.2

How to reduce bundle size | Import cost

Current Behavior

image

The import cost is very expensive, and the size is still the same as the amount of components imported reduced

Expected behavior

The import cost only takes on what component is being used

Suggested solution(s)

I have tried few things such as reducing reexporting components, but it doesn't work

Additional context

N / A

Your environment

System:
    OS: Windows 10 10.0.22000
    CPU: (16) x64 AMD Ryzen 7 5800H with Radeon Graphics
    Memory: 2.47 GB / 13.86 GB
  Binaries:
    Node: 16.13.2 - C:\Program Files\nodejs\node.EXE
    Yarn: 1.22.19 - ~\AppData\Roaming\npm\yarn.CMD
    npm: 8.1.2 - C:\Program Files\nodejs\npm.CMD
  Managers:
    Cargo: 1.61.0 - ~\.cargo\bin\cargo.EXE
  Utilities:
    Git: 2.34.1. - /mingw64/bin/git
  IDEs:
    VSCode: 1.68.1 - C:\Users\bryan\AppData\Local\Programs\Microsoft VS Code\bin\code.CMD
  Languages:
    Bash: 4.4.23 - C:\Program Files\Git\usr\bin\bash.EXE
    Perl: 5.34.0 - C:\Program Files\Git\usr\bin\perl.EXE
    Rust: 1.61.0 - /c/Users/bryan/.cargo/bin/rustc
  Browsers:
    Edge: Spartan (44.22000.120.0), Chromium (102.0.1245.44)
    Internet Explorer: 11.0.22000.120

VSCode ESLint plugin does not work with dts-cli project

Current Behavior

After creating a new react library using dts-cli, the ESLint Plugin of VSCode won't work out-of-the-box.

Expected behavior

ESLint Plugin of VSCode should work without any additional tinkering

Suggested solution(s)

Not sure how one could fix it, but it seems like the extension cant find the right config to pick.

Additional context

[Info  - 11:19:28 AM] ESLint server is starting
[Info  - 11:19:28 AM] ESLint server running in node v16.13.0
[Info  - 11:19:28 AM] ESLint server is running.
[Info  - 11:19:29 AM] ESLint library loaded from: /Users/dummy/react-libs/dts-test/node_modules/eslint/lib/api.js
[Warn  - 11:19:29 AM] 
No ESLint configuration (e.g .eslintrc) found for file: /Users/dummy/react-libs/dts-test/src/index.tsx
File will not be validated. Consider running 'eslint --init' in the workspace folder dts-test
Alternatively you can disable ESLint by executing the 'Disable ESLint' command.

Your environment

System:
    OS: macOS 12.1
    CPU: (8) x64 Intel(R) Core(TM) i5-8257U CPU @ 1.40GHz
    Memory: 701.05 MB / 16.00 GB
    Shell: 5.8 - /bin/zsh
  Binaries:
    Node: 16.14.2 - /usr/local/bin/node
    Yarn: 1.19.1 - ~/.yarn/bin/yarn
    npm: 8.5.0 - /usr/local/bin/npm
  Browsers:
    Brave Browser: 98.1.35.100
    Chrome: 100.0.4896.127
    Firefox: 98.0.2
    Safari: 15.2
  npmPackages:
    dts-cli: ^1.5.0 => 1.5.0 
    typescript: ^4.6.3 => 4.6.3 

noClean option for build

Current Behavior

The watch command features a noClean option which does not clean the build folder. The build command does not.

Desired Behavior

We'd like to run multiple build commands (for multiple entries until #55 is supported) and would like to retain the dist folder between those.

Suggested Solution

Add the same noClean option to the build command too.

Who does this impact? Who is this for?

Some advanced usages / edge cases.

Describe alternatives you've considered

Named exports from a barrel file.

Additional context

Any plans to migrate Parcel to V2?

Current Behavior

image

The weird part is that inside the devDependencies, parcel is ^1.12.3,
but when I run npm i and npm outdated, parcel is always installed as 1.12.4 due to some dep dependency requirement.

The current project will always fail in /example project due to the Parcel bug.
It's been discussed for a while but it seems like this forks does not address this critical issue.

So I had to do hard roll back to 1,12.3 by npm i [email protected], which creates some questionable warnings.

Though it's just a example playground that has nothing to do with the true package, the developer experience is quite unpleasing.

image

Expected behavior

Run npm run start without problems

Suggested solution(s)

Additional context

Your environment

windows


Thanks y’all

No bug/issue, just wanted to say thanks to y'all at weiran-zsd for picking up the slack on tsdx.

Could not resolve './error.less' - rollup-plugin-dts seems does not play well with css/json modules

Current Behavior

import "./error.less";
// global.d.ts
declare module '*.less' {
    const content: { [key: string]: any }
    export default content
}
'react-photo-view/dist/index.css' is imported by dist/types/components/image-upload/index.d.ts, but could not be resolved Error: Could not resolve './error.less' from dist/types/components/error/index.d.ts

Expected behavior

Suggested solution(s)

it was introduced in 26a6950. the error was like Swatinem/rollup-plugin-dts#184.

I think it's fine to make the rollup-plugin-dts behind the option, as seems not well compat with css/json modules.

Additional context

Your environment

  System:
    OS: macOS 12.2
    CPU: (8) x64 Intel(R) Core(TM) i7-1068NG7 CPU @ 2.30GHz
    Memory: 3.68 GB / 32.00 GB
    Shell: 5.8 - /bin/zsh
  Binaries:
    Node: 17.2.0 - /usr/local/bin/node
    Yarn: 1.22.17 - ~/.npm-global/bin/yarn
    npm: 8.2.0 - ~/.npm-global/bin/npm
    Watchman: 20200920.192359.0 - /usr/local/bin/watchman
  Browsers:
    Brave Browser: 83.1.10.93
    Chrome: 96.0.4664.110
    Edge: 96.0.1054.62
    Safari: 15.3
  npmPackages:
    dts-cli: ^1.1.1 => 1.1.1 
  npmGlobalPackages:
    dts-cli: 0.20.0
    typescript: 4.5.2

Consider upgrading to Jest 29 and Eslint 8

Current Behavior

Jest is on v27 and eslint is on v7

Desired Behavior

Jest and Eslint have bump major versions to v29 and v8 respectively

Suggested Solution

Updated package.json with the new versions... note Jest 29 requires you to import a new library

Who does this impact? Who is this for?

All users who want the latest technologies

Describe alternatives you've considered

Switching to a new bundler

Add support for `npx dtx create .`

Current Behavior

If I have an existing project folder or repository, I first run npx dtx create foo, then copy the contents of foo to the root of my project.

Desired Behavior

First cd into an existing project folder, then run npx dtx create . This should then setup all files and folders in the root of the project folder.

Suggested Solution

I suggest using a similar implementation as npx create-next-app . or npx create-react-app .

Skjermbilde 2022-08-01 kl  23 40 23

`yarn lint` fails when choosing react-storybook template

Current Behavior

After creating a new dts-cli project, choosing the react-storybook template, running yarn lint will fail due to not being able to load eslint-plugin-prettier correctly.

Expected behavior

yarn lint works without any problems

Suggested solution(s)

Installing eslint-plugin-prettier helps get rid of the error message, but it does not seem to be the intended way, since for the react template it works out of the box (and there it is also missing in the package.json)

Additional context

It apparently only fails in the react-storybook template.

yarn run v1.19.1
$ dts lint
Defaulting to "dts lint src test" 
You can override this in the package.json scripts, like "lint": "dts lint src otherDir"
Error: Failed to load plugin 'prettier' declared in 'BaseConfig': Cannot find module 'eslint-plugin-prettier'
Require stack:
- /Users/dummy/react-libs/dts-test-storybook/__placeholder__.js
Referenced from: BaseConfig
    at Function.Module._resolveFilename (node:internal/modules/cjs/loader:933:15)
    at Function.resolve (node:internal/modules/cjs/helpers:108:19)
    at Object.resolve (/Users/dummy/react-libs/dts-test-storybook/node_modules/@eslint/eslintrc/dist/eslintrc.cjs:2325:46)
    at ConfigArrayFactory._loadPlugin (/Users/dummy/react-libs/dts-test-storybook/node_modules/@eslint/eslintrc/dist/eslintrc.cjs:3376:33)
    at ConfigArrayFactory._loadExtendedPluginConfig (/Users/dummy/react-libs/dts-test-storybook/node_modules/@eslint/eslintrc/dist/eslintrc.cjs:3196:29)
    at ConfigArrayFactory._loadExtends (/Users/dummy/react-libs/dts-test-storybook/node_modules/@eslint/eslintrc/dist/eslintrc.cjs:3117:29)
    at ConfigArrayFactory._normalizeObjectConfigDataBody (/Users/dummy/react-libs/dts-test-storybook/node_modules/@eslint/eslintrc/dist/eslintrc.cjs:3058:25)
    at _normalizeObjectConfigDataBody.next (<anonymous>)
    at ConfigArrayFactory._normalizeObjectConfigData (/Users/dummy/react-libs/dts-test-storybook/node_modules/@eslint/eslintrc/dist/eslintrc.cjs:3003:20)
    at _normalizeObjectConfigData.next (<anonymous>) {
  code: 'MODULE_NOT_FOUND',
  requireStack: [
    '/Users/dummy/react-libs/dts-test-storybook/__placeholder__.js'
  ],
  messageTemplate: 'plugin-missing',
  messageData: {
    pluginName: 'eslint-plugin-prettier',
    resolvePluginsRelativeTo: '/Users/dummy/react-libs/dts-test-storybook',
    importerName: 'BaseConfig'
  }
}
error Command failed with exit code 1.
info Visit https://yarnpkg.com/en/docs/cli/run for documentation about this command.

Your environment

System:
    OS: macOS 12.1
    CPU: (8) x64 Intel(R) Core(TM) i5-8257U CPU @ 1.40GHz
    Memory: 701.05 MB / 16.00 GB
    Shell: 5.8 - /bin/zsh
  Binaries:
    Node: 16.14.2 - /usr/local/bin/node
    Yarn: 1.19.1 - ~/.yarn/bin/yarn
    npm: 8.5.0 - /usr/local/bin/npm
  Browsers:
    Brave Browser: 98.1.35.100
    Chrome: 100.0.4896.127
    Firefox: 98.0.2
    Safari: 15.2
  npmPackages:
    dts-cli: ^1.5.0 => 1.5.0 
    typescript: ^4.6.3 => 4.6.3 

Add type-fest as a devDependency and fix build failure with newer versions

Current Behavior

Currently it is pulled in as an indirect dependency even though it is directly required in src/templates/react-with-storybook.ts

Expected behavior

Any modules directly used in src/* should be explicitly mentioned in package.json

Suggested solution(s)

Just add types-fest as a direct devDependency, this will also gives flexibility with which exact version is pulled in.

Additional context

When type-fest 0.18.0 is used build fails with this error,

src/templates/basic.ts(47,5): error TS2322: Type '{ version: string; license: string; main: string; typings: string; files: string[]; engines: { node: string; }; scripts: { start: string; build: string; test: string; lint: string; prepare: string; size: string; analyze: string; }; peerDependencies: {}; husky: { ...; }; prettier: { ...; }; }' is not assignable to type 'PackageJson'.
  Object literal may only specify known properties, and 'husky' does not exist in type 'PackageJson'.

Your environment

I'm trying to build tsdx as a native debian package.


Support for react-jsx compiler

Current Behavior

If I remove the import of React, build fails with message:
'React' refers to a UMD global, but the current file is a module. Consider adding an import instead.

Expected behavior

the import of React it's not necessary.

dts export

I wish there was a way we could run export like you can for create-react-app where it will unpack all the config files that it uses as well as install any packages it's using under the hood. So that we could update and tweak everything

Error when trying to use useState

Current Behavior

Without making any changes besides adding a useState to the component <Thing /> in the src file I'm getting this error:
TypeError: Cannot read properties of null (reading 'useState')

I'm not getting any errors in the DTS app console or my app console, it is compiling without errors or warnings. The error is showing when the component tries to mount. If I remove the useState my app is working fine.

This is how the code of the component looks like:

Screen Shot 2022-07-06 at 18 33 26

And this is the error I'm getting:

Screen Shot 2022-07-06 at 18 31 29

Expected behavior

Suggested solution(s)

Additional context

Your environment


dts lint --write-file outputs absolute path to eslint-config-react-app in .eslintrc.js

Current Behavior

dts lint --write-file produces the following .eslintrc.js in v1.1.3:

module.exports = {
    extends: [
        "/Users/user/my-project/node_modules/dts-cli/conf/eslint-config-react-app/index.js",
        "prettier",
        "plugin:prettier/recommended",
    ],
    settings: {
        react: {
            version: "detect",
        },
    },
};

Expected behavior

dts lint --write-file should not be including absolute paths in the .eslintrc.js

Suggested solution(s)

Output path relative to the project root.

v2 changes

it won't happen soon, just want to list all the possible things:

feature: remove husky

Current Behavior

when init project with dts-cli, it installs husky, which breaks the hooks of git when in monorepo.

Desired Behavior

no husky installed, or there is options in the cli

Suggested Solution

add a question to decide if husky needed.

Unable to make a commit unless doctoc is installed in global scope

Current Behavior

Local commits fail unless doctoc is installed in global scope.

.husky/pre-commit: line 7: doctoc: command not found
husky - pre-commit hook exited with code 127 (error)

This is happening due to pre-commit hook:

yarn pretty-quick --staged --pattern '!test/tests/lint/**'
yarn lint
yarn deduplicate:check
doctoc README.md       <----- this line is breaking commit

Expected behavior

I should be able to commit changes without installing doctoc globally.

Suggested solution(s)

  • create doctoc script in package.json
  • invoke it via yarn doctoc in husky pre-commit hook

add lint-staged

Current Behavior

lint-staged is not installed

Desired Behavior

As we already include husky, I think it would be nice if dts-cli would include lint-staged as well.

Suggested Solution

Include lint-staged as part of the setup

Who does this impact? Who is this for?

All users

`yarn build` do not include dependencies in generated bundle

Current Behavior

When I run yarn build command, packge.json dependencies are not added to the bundle.

Expected behavior

package.json dependencies should be included to the bundle.

Suggested solution(s)

Additional context

I'm building a NodeJS package and it can be found here.

Your environment

  System:
    OS: Linux 5.15 Ubuntu 22.04 LTS 22.04 LTS (Jammy Jellyfish)
    CPU: (4) x64 Intel(R) Core(TM) i3-1005G1 CPU @ 1.20GHz
    Memory: 6.12 GB / 11.44 GB
    Container: Yes
    Shell: 5.1.16 - /bin/bash
  Binaries:
    Node: 16.15.1 - ~/.nvm/versions/node/v16.15.1/bin/node
    Yarn: 1.22.19 - ~/.nvm/versions/node/v16.15.1/bin/yarn
    npm: 8.15.1 - ~/.nvm/versions/node/v16.15.1/bin/npm
  Browsers:
    Brave Browser: 103.1.41.100
    Chrome: 103.0.5060.134
  npmPackages:
    dts-cli: ^1.5.2 => 1.5.2 
    typescript: ^4.7.4 => 4.7.4 
  npmGlobalPackages:
    typescript: 4.7.4

husky is installed, but not initialized

Current Behavior

When creating a project, husky is installed, but as there is no git repo, husky isn't initialized.

npx dts-cli create my-project

Expected behavior

pre-commit hooks should be initialized.

Suggested solution(s)

Run git init before installing node modules

Additional context

Your environment

  System:
    OS: macOS 12.3.1
    CPU: (10) arm64 Apple M1 Pro
    Memory: 120.61 MB / 32.00 GB
    Shell: 3.3.1 - /opt/homebrew/bin/fish
  Binaries:
    Node: 16.14.0 - ~/.nvm/versions/node/v16.14.0/bin/node
    Yarn: 1.22.17 - /opt/homebrew/bin/yarn
    npm: 8.3.1 - ~/.nvm/versions/node/v16.14.0/bin/npm
  Browsers:
    Chrome: 102.0.5005.61
    Firefox: 99.0.1
    Safari: 15.4
  npmPackages:
    dts-cli: ^1.5.1 => 1.5.1 
    typescript: ^4.7.3 => 4.7.3 

Dependency Dashboard

This issue lists Renovate updates and detected dependencies. Read the Dependency Dashboard docs to learn more.

Rate-Limited

These updates are currently rate-limited. Click on a checkbox below to force their creation now.

  • chore(deps): update dependency styled-components to v6
  • fix(deps): update dependency @rollup/plugin-commonjs to v26
  • fix(deps): update dependency camelcase to v8
  • fix(deps): update dependency eslint-config-prettier to v9
  • fix(deps): update dependency eslint-plugin-jest to v28
  • fix(deps): update dependency eslint-plugin-prettier to v5
  • fix(deps): update dependency eslint-plugin-testing-library to v6
  • fix(deps): update dependency execa to v9
  • fix(deps): update dependency pascal-case to v4
  • fix(deps): update dependency rollup-plugin-dts to v6
  • fix(deps): update dependency type-fest to v4
  • fix(deps): update typescript-eslint monorepo to v7 (major) (@typescript-eslint/eslint-plugin, @typescript-eslint/parser)
  • 🔐 Create all rate-limited PRs at once 🔐

Open

These updates have all been created already. Click a checkbox below to force a retry/rebase of any.

Detected dependencies

github-actions
.github/workflows/nodejs.yml
  • actions/checkout v4
  • actions/setup-node v4
  • actions/checkout v4
  • actions/setup-node v4
templates/basic/.github/workflows/main.yml
  • actions/checkout v4
  • actions/setup-node v4
templates/basic/.github/workflows/size.yml
  • actions/checkout v4
  • andresz1/size-limit-action v1
templates/react-with-storybook/.github/workflows/main.yml
  • actions/checkout v4
  • actions/setup-node v4
templates/react-with-storybook/.github/workflows/size.yml
  • actions/checkout v4
  • andresz1/size-limit-action v1
templates/react/.github/workflows/main.yml
  • actions/checkout v4
  • actions/setup-node v4
templates/react/.github/workflows/size.yml
  • actions/checkout v4
  • andresz1/size-limit-action v1
npm
conf/eslint-config-react-app/package.json
  • @babel/core ^7.24.3
  • @babel/eslint-parser ^7.24.1
  • @rushstack/eslint-patch ^1.10.1
  • @typescript-eslint/eslint-plugin ^5.62.0
  • @typescript-eslint/parser ^5.62.0
  • babel-preset-react-app ^10.0.1
  • confusing-browser-globals ^1.0.11
  • eslint-plugin-flowtype ^8.0.3
  • eslint-plugin-import ^2.29.1
  • eslint-plugin-jest ^26.9.0
  • eslint-plugin-jsx-a11y ^6.8.0
  • eslint-plugin-react ^7.34.1
  • eslint-plugin-react-hooks ^4.6.0
  • eslint-plugin-testing-library ^5.11.1
package.json
  • @babel/core ^7.24.3
  • @babel/helper-module-imports ^7.24.3
  • @babel/parser ^7.24.1
  • @babel/plugin-proposal-class-properties ^7.18.6
  • @babel/preset-env ^7.24.3
  • @babel/traverse ^7.24.1
  • @rollup/plugin-babel ^6.0.4
  • @rollup/plugin-commonjs ^24.1.0
  • @rollup/plugin-json ^6.1.0
  • @rollup/plugin-node-resolve ^15.2.3
  • @rollup/plugin-replace ^5.0.5
  • @rollup/plugin-terser ^0.4.4
  • @types/jest ^29.5.12
  • @typescript-eslint/eslint-plugin ^5.62.0
  • @typescript-eslint/parser ^5.62.0
  • asyncro ^3.0.0
  • babel-jest ^29.7.0
  • babel-plugin-annotate-pure-calls ^0.4.0
  • babel-plugin-dev-expression ^0.2.3
  • babel-plugin-macros ^3.1.0
  • babel-plugin-polyfill-regenerator ^0.6.1
  • babel-plugin-transform-rename-import ^2.3.0
  • camelcase ^6.3.0
  • chalk ^4.1.2
  • confusing-browser-globals ^1.0.11
  • enquirer ^2.4.1
  • eslint-config-prettier ^8.10.0
  • eslint-plugin-flowtype ^8.0.3
  • eslint-plugin-import ^2.29.1
  • eslint-plugin-jest ^27.9.0
  • eslint-plugin-jsx-a11y ^6.8.0
  • eslint-plugin-prettier ^4.2.1
  • eslint-plugin-react ^7.34.1
  • eslint-plugin-react-hooks ^4.6.0
  • eslint-plugin-testing-library ^5.11.1
  • execa ^4.1.0
  • figlet ^1.7.0
  • fs-extra ^10.1.0
  • jest-environment-jsdom ^29.7.0
  • jest-watch-typeahead ^2.2.2
  • jpjs ^1.2.1
  • lodash.merge ^4.6.2
  • pascal-case ^3.1.2
  • postcss ^8.4.38
  • progress-estimator ^0.3.1
  • regenerator-runtime ^0.14.1
  • rollup-plugin-delete ^2.0.0
  • rollup-plugin-dts ^5.3.1
  • rollup-plugin-typescript2 ^0.36.0
  • sade ^1.8.1
  • semver ^7.6.0
  • shelljs ^0.8.5
  • sort-package-json ^1.57.0
  • tiny-glob ^0.2.9
  • ts-jest ^29.1.2
  • ts-node ^10.9.2
  • tslib ^2.6.2
  • type-fest ^2.19.0
  • @commitlint/cli ^16.3.0
  • @commitlint/config-conventional ^16.2.4
  • @release-it/conventional-changelog ^5.1.1
  • @types/cssnano ^5.1.0
  • @types/eslint ^8.56.7
  • @types/figlet ^1.5.8
  • @types/fs-extra ^9.0.13
  • @types/lodash ^4.17.0
  • @types/node ^16.18.94
  • @types/react ^18.2.74
  • @types/rollup-plugin-json ^3.0.7
  • @types/semver ^7.5.8
  • @types/shelljs ^0.8.15
  • @types/styled-components ^5.1.34
  • auto-changelog ^2.4.0
  • autoprefixer ^10.4.19
  • babel-plugin-replace-identifiers ^0.1.1
  • cssnano ^5.1.15
  • doctoc ^2.2.1
  • husky ^8.0.3
  • lint-staged ^15.2.2
  • release-it ^15.11.0
  • rollup-plugin-postcss ^4.0.2
  • styled-components ^5.3.11
  • tiny-invariant ^1.3.3
  • tiny-warning ^1.0.3
templates/react-with-storybook/example/package.json
  • react-app-polyfill ^3.0.0
  • @types/react ^18.2.74
  • @types/react-dom ^18.2.23
templates/react/example/package.json
  • react-app-polyfill ^3.0.0
  • @types/react ^18.2.74
  • @types/react-dom ^18.2.23
test/e2e/fixtures/build-default/package.json
test/e2e/fixtures/build-invalid/package.json
test/e2e/fixtures/build-multipleEntries/package.json
test/e2e/fixtures/build-withTsconfig/package.json
test/e2e/fixtures/build-withTypesRollup/package.json
test/integration/fixtures/build-options/package.json
test/integration/fixtures/build-withBabel/package.json
test/integration/fixtures/build-withConfig-defineConfig/package.json
test/integration/fixtures/build-withConfig/package.json
test/integration/fixtures/build-withConfigTs-defineConfig/package.json
test/integration/fixtures/build-withConfigTs-noRollup/package.json
test/integration/fixtures/build-withConfigTs/package.json

  • Check this box to trigger a request for Renovate to run again on this repository

Disable minification by default

Current Behavior

dts-cli currently creates minified builds by default. This is problematic because it makes auditing the produced libraries (as a third party) much more difficult, even though there's not really any purpose to building minified libraries - anybody using a module system is very likely to already have their own minification tooling set up, since they will need it for their own application code anyway.

Expected behavior

Only producing unminified builds by default, including for production builds.

Suggested solution(s)

Disabling minified builds by default, clearly documenting this, and allowing the user to re-enable minified builds (for which there is already a configuration option).

Additional context

I've written a more detailed article here about the issues with minified builds in packages, and why it's better to not include them, also addressing some common concerns. If you have a concern that isn't covered there, I'd be happy to address it, of course :)

Especially because dts-cli isn't just a single library but rather a tool used to produce libraries, the default setting makes a lot of difference in how easy it is for people to audit their dependency trees - people tend to stick with defaults most of the time, and so whether a tool like this enables them by default or not can have a big overnight impact on many different packages.

(I'll also be filing a similar issue on tsdx, if it turns out to enable minification by default as well)

Your environment

N/A

adding pkg.exports in all templates

image

most of the toolings have supported it, it can be considerable to add it in the templates:

{
  "name": "my-lib",
  "files": ["dist"],
  "main": "./dist/my-lib.cjs",
  "module": "./dist/my-lib.mjs",
  "exports": {
    ".": {
      "import": "./dist/my-lib.mjs",
      "require": "./dist/my-lib.cjs"
    }
  }
}

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.