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

some type-only TS files are ignored when using tsconfig files? #409

Closed
ZHHHH9980 opened this issue Aug 17, 2022 · 5 comments · Fixed by #406
Closed

some type-only TS files are ignored when using tsconfig files? #409

ZHHHH9980 opened this issue Aug 17, 2022 · 5 comments · Fixed by #406
Labels
kind: bug Something isn't working properly problem: plugin order The plugin order in this issue seems incompatible. See the "Compatibility" section in the README problem: removed issue template OP removed the issue template without good cause solution: duplicate This issue or pull request already exists solution: workaround available There is a workaround available for this issue topic: type-only / emit-less imports Related to importing type-only files that will not be emitted

Comments

@ZHHHH9980
Copy link

ZHHHH9980 commented Aug 17, 2022

What happens and why it is incorrect

there are many files ending in *.ts in the src, but only some have been transpiled

  1. Does tsc have the same output? If so, please explain why this is incorrect behavior

NO, tsc run as expectly.
image

here's file structure:
image

but rpt2 seems to ignore the file named component.ts:
image

Environment

Versions

System:
    OS: macOS 11.4
    CPU: (12) x64 Intel(R) Core(TM) i7-9750H CPU @ 2.60GHz
    Memory: 59.11 MB / 32.00 GB
    Shell: 5.8 - /bin/zsh
  Binaries:
    Node: 14.17.4 - ~/.nvm/versions/node/v14.17.4/bin/node
    Yarn: 1.22.11 - ~/.nvm/versions/node/v14.17.4/bin/yarn
    npm: 6.14.14 - ~/.nvm/versions/node/v14.17.4/bin/npm
  npmPackages:
    rollup: ^2.45.2 => 2.45.2
    rollup-plugin-typescript2: ^0.30.0 => 0.30.0
    typescript: ^4.3.5 => 4.3.5
  npmGlobalPackages:
    typescript: 4.3.5

rollup.config.js

:
import { nodeResolve } from '@rollup/plugin-node-resolve';

import replace from '@rollup/plugin-replace';
import postcss from 'rollup-plugin-postcss';
import image from '@rollup/plugin-image';
import ts from 'rollup-plugin-typescript2';
import dts from 'rollup-plugin-dts';
import json from '@rollup/plugin-json';
import alias from '@rollup/plugin-alias';
import autoExternal from 'rollup-plugin-auto-external';
import path from 'path';
import importCss from './rollup-plugin-import-css';

const resolve = (...dirs) => path.resolve(__dirname, '../', ...dirs);

function toUpperCase(match) {
  return match.replace('-', '').toUpperCase();
}

export default [
  {
    input: resolve('src/lib/index.tsx'),
    output: [
      {
        file: resolve('dist/index.esm.js'),
        format: 'es',
        sourcemap: true,
      },
    ],

    external: id => {
      try {
        const idSourcePath = require.resolve(id, { paths: [resolve()] });
        return idSourcePath && idSourcePath.includes('node_modules');
      } catch (error) {
        return false;
      }
    },
    plugins: [
      ts({
        check: false,
        tsconfig: resolve('tsconfig.json'),
        tsconfigOverride: {
          compilerOptions: { declaration: true, declarationDir: resolve('dist/type') },
        },
        verbosity: 2,
        useTsconfigDeclarationDir: true,
        include: ['*.ts+(|x)', '**/*.ts+(|x)', '*.js+(|x)', '**/*.js+(|x)'],
      }),
      image(),
      postcss({
        extensions: ['.css', '.scss', '.less'],
        autoModules: true,
        extract: 'index.css',
        namedExports(name) {
          let reg = /-[a-z]/g;
          const temp = name.replace(reg, toUpperCase);
          return temp;
        },
      }),
      json(),
      alias({
        entries: [
          {
            find: 'src',
            replacement: resolve('src'),
          },
        ],
      }),
      nodeResolve({
        extensions: ['.js', '.jsx', '.ts', '.tsx'],
        // some package.json files have a "browser" field which specifies
        // alternative files to load for people bundling for the browser. If
        // that's you, either use this option or add "browser" to the
        // "mainfields" option, otherwise pkg.browser will be ignored
        browser: true,
        preferBuiltins: true,
        mainFields: ['browser', 'jsnext', 'module', 'main'],
      }),
      replace({
        'process.env.NODE_ENV': JSON.stringify('development'),
        'process.env.SEMI_ICON_LAZY_LOAD': true,
        preventAssignment: true,
      }),
      autoExternal({
        packagePath: resolve(),
      }),
      importCss(),
    ],
  },
  {
    input: resolve('dist/type/src/lib/index.d.ts'),
    external: id => {
      try {
        const idSourcePath = require.resolve(id, { paths: [resolve()] });
        return idSourcePath && idSourcePath.includes('node_modules');
      } catch (error) {
        return false;
      }
    },
    output: [{ file: resolve('dist/index.d.ts'), format: 'es' }],
    plugins: [dts()],
  },
];

tsconfig.json

:
{
  "compilerOptions": {
    "target": "es6",
    "module": "esnext",
    "lib": ["es7", "dom"],
    "sourceMap": true,
    "allowJs": true,
    "jsx": "react",
    "moduleResolution": "node",
    "experimentalDecorators": true,
    "rootDir": "./",
    "baseUrl": "./src",
    "forceConsistentCasingInFileNames": true,
    "noImplicitReturns": true,
    "noImplicitThis": false,
    "noImplicitAny": false,
    "importHelpers": true,
    "strictNullChecks": false,
    "suppressImplicitAnyIndexErrors": true,
    "noUnusedLocals": true,
    "noEmit": true,
    "allowSyntheticDefaultImports": true,
    "esModuleInterop": false,
    "paths": {
      "@ies/kefu-editor": ["src/lib/*"]
    },
    "plugins": [
      {
        "transform": "ts-optchain/transform"
      }
    ]
  },
  "typeRoots": ["node", "node_modules/@types", "./src/typings"],
  "exclude": ["node_modules"]
}

package.json

:

plugin output with verbosity 3

:
/Users/bytedance/Public/helpdesk-semi-ui/packages/KefuCascaderTable/src/lib/index.tsx → dist/index.esm.js...
rpt2: built-in options overrides: {
    "noEmitHelpers": false,
    "importHelpers": true,
    "noResolve": false,
    "noEmit": false,
    "inlineSourceMap": false,
    "outDir": "/Users/bytedance/Public/helpdesk-semi-ui/packages/KefuCascaderTable/node_modules/.cache/rollup-plugin-typescript2/placeholder",
    "moduleResolution": 2,
    "allowNonTsExtensions": true
}
rpt2: parsed tsconfig: {
    "options": {
        "isolatedModules": false,
        "declaration": true,
        "target": 2,
        "module": 99,
        "lib": [
            "lib.es2016.d.ts",
            "lib.dom.d.ts"
        ],
        "sourceMap": true,
        "allowJs": true,
        "jsx": 2,
        "moduleResolution": 2,
        "experimentalDecorators": true,
        "rootDir": "/Users/bytedance/Public/helpdesk-semi-ui/packages/KefuCascaderTable",
        "baseUrl": "/Users/bytedance/Public/helpdesk-semi-ui/packages/KefuCascaderTable/src",
        "forceConsistentCasingInFileNames": true,
        "noImplicitReturns": true,
        "noImplicitThis": false,
        "noImplicitAny": false,
        "importHelpers": true,
        "strictNullChecks": false,
        "suppressImplicitAnyIndexErrors": true,
        "noUnusedLocals": true,
        "allowSyntheticDefaultImports": true,
        "esModuleInterop": false,
        "paths": {
            "@ies/kefu-tag-table": [
                "src/lib/*"
            ]
        },
        "plugins": [
            {
                "transform": "ts-optchain/transform"
            }
        ],
        "declarationDir": "/Users/bytedance/Public/helpdesk-semi-ui/packages/KefuCascaderTable/dist/type",
        "configFilePath": "/Users/bytedance/Public/helpdesk-semi-ui/packages/KefuCascaderTable/tsconfig.json",
        "pathsBasePath": "/Users/bytedance/Public/helpdesk-semi-ui/packages/KefuCascaderTable",
        "noEmitHelpers": false,
        "noResolve": false,
        "noEmit": false,
        "inlineSourceMap": false,
        "outDir": "/Users/bytedance/Public/helpdesk-semi-ui/packages/KefuCascaderTable/node_modules/.cache/rollup-plugin-typescript2/placeholder",
        "allowNonTsExtensions": true
    },
    "fileNames": [
        "/Users/bytedance/Public/helpdesk-semi-ui/packages/KefuCascaderTable/src/lib/index.tsx"
    ],
    "typeAcquisition": {
        "enable": false,
        "include": [],
        "exclude": []
    },
    "raw": {
        "files": [
            "src/lib/index.tsx"
        ],
        "compilerOptions": {
            "isolatedModules": false,
            "declaration": true,
            "target": "es6",
            "module": "esnext",
            "lib": [
                "es7",
                "dom"
            ],
            "sourceMap": true,
            "allowJs": true,
            "jsx": "react",
            "moduleResolution": "node",
            "experimentalDecorators": true,
            "rootDir": "./",
            "baseUrl": "./src",
            "forceConsistentCasingInFileNames": true,
            "noImplicitReturns": true,
            "noImplicitThis": false,
            "noImplicitAny": false,
            "importHelpers": true,
            "strictNullChecks": false,
            "suppressImplicitAnyIndexErrors": true,
            "noUnusedLocals": true,
            "allowSyntheticDefaultImports": true,
            "esModuleInterop": false,
            "paths": {
                "@ies/kefu-tag-table": [
                    "src/lib/*"
                ]
            },
            "plugins": [
                {
                    "transform": "ts-optchain/transform"
                }
            ],
            "declarationDir": "/Users/bytedance/Public/helpdesk-semi-ui/packages/KefuCascaderTable/dist/type"
        },
        "typeRoots": [
            "node",
            "node_modules/@types",
            "./src/typings"
        ],
        "exclude": [
            "node_modules"
        ],
        "compileOnSave": false
    },
    "errors": [],
    "wildcardDirectories": {},
    "compileOnSave": false
}
rpt2: typescript version: 4.3.5
rpt2: tslib version: 2.1.0
rpt2: rollup version: 2.45.2
rpt2: rollup-plugin-typescript2 version: 0.30.0
rpt2: plugin options:
{
    "check": false,
    "tsconfig": "/Users/bytedance/Public/helpdesk-semi-ui/packages/KefuCascaderTable/tsconfig.json",
    "tsconfigOverride": {
        "compilerOptions": {
            "declaration": true,
            "declarationDir": "/Users/bytedance/Public/helpdesk-semi-ui/packages/KefuCascaderTable/dist/type"
        }
    },
    "verbosity": 3,
    "useTsconfigDeclarationDir": true,
    "include": [
        "*.ts+(|x)",
        "**/*.ts+(|x)",
        "*.js+(|x)",
        "**/*.js+(|x)"
    ],
    "clean": false,
    "cacheRoot": "/Users/bytedance/Public/helpdesk-semi-ui/packages/KefuCascaderTable/node_modules/.cache/rollup-plugin-typescript2",
    "exclude": [
        "*.d.ts",
        "**/*.d.ts"
    ],
    "abortOnError": true,
    "rollupCommonJSResolveHack": false,
    "transformers": [],
    "tsconfigDefaults": {},
    "objectHashIgnoreUnknownHack": false,
    "cwd": "/Users/bytedance/Public/helpdesk-semi-ui/packages/KefuCascaderTable",
    "typescript": "version 4.3.5"
}
rpt2: rollup config:
{
    "input": "/Users/bytedance/Public/helpdesk-semi-ui/packages/KefuCascaderTable/src/lib/index.tsx",
    "plugins": [
        {
            "name": "rpt2"
        },
        {
            "name": "image"
        },
        {
            "name": "postcss"
        },
        {
            "name": "json"
        },
        {
            "name": "alias"
        },
        {
            "name": "node-resolve"
        },
        {
            "name": "replace"
        },
        {
            "name": "auto-external"
        },
        {},
        {
            "name": "stdin"
        }
    ],
    "output": [
        {
            "file": "/Users/bytedance/Public/helpdesk-semi-ui/packages/KefuCascaderTable/dist/index.esm.js",
            "format": "es",
            "plugins": [],
            "sourcemap": true
        }
    ]
}
rpt2: tsconfig path: /Users/bytedance/Public/helpdesk-semi-ui/packages/KefuCascaderTable/tsconfig.json
rpt2: included:
[
    "*.ts+(|x)",
    "**/*.ts+(|x)",
    "*.js+(|x)",
    "**/*.js+(|x)"
]
rpt2: excluded:
[
    "*.d.ts",
    "**/*.d.ts"
]
rpt2: Ambient types:
rpt2:     /Users/bytedance/Public/helpdesk-semi-ui/packages/KefuCascaderTable/node_modules/@types/babel__core/index.d.ts
rpt2:     /Users/bytedance/Public/helpdesk-semi-ui/packages/KefuCascaderTable/node_modules/@types/babel__generator/index.d.ts
rpt2:     /Users/bytedance/Public/helpdesk-semi-ui/packages/KefuCascaderTable/node_modules/@types/babel__template/index.d.ts
rpt2:     /Users/bytedance/Public/helpdesk-semi-ui/packages/KefuCascaderTable/node_modules/@types/babel__traverse/index.d.ts
rpt2:     /Users/bytedance/Public/helpdesk-semi-ui/packages/KefuCascaderTable/node_modules/@types/color-name/index.d.ts
rpt2:     /Users/bytedance/Public/helpdesk-semi-ui/packages/KefuCascaderTable/node_modules/@types/css-modules-loader-core/index.d.ts
rpt2:     /Users/bytedance/Public/helpdesk-semi-ui/packages/KefuCascaderTable/node_modules/@types/estree/index.d.ts
rpt2:     /Users/bytedance/Public/helpdesk-semi-ui/packages/KefuCascaderTable/node_modules/@types/graceful-fs/index.d.ts
rpt2:     /Users/bytedance/Public/helpdesk-semi-ui/packages/KefuCascaderTable/node_modules/@types/hast/index.d.ts
rpt2:     /Users/bytedance/Public/helpdesk-semi-ui/packages/KefuCascaderTable/node_modules/@types/istanbul-lib-coverage/index.d.ts
rpt2:     /Users/bytedance/Public/helpdesk-semi-ui/packages/KefuCascaderTable/node_modules/@types/istanbul-lib-report/index.d.ts
rpt2:     /Users/bytedance/Public/helpdesk-semi-ui/packages/KefuCascaderTable/node_modules/@types/istanbul-reports/index.d.ts
rpt2:     /Users/bytedance/Public/helpdesk-semi-ui/packages/KefuCascaderTable/node_modules/@types/jest/index.d.ts
rpt2:     /Users/bytedance/Public/helpdesk-semi-ui/packages/KefuCascaderTable/node_modules/@types/json-schema/index.d.ts
rpt2:     /Users/bytedance/Public/helpdesk-semi-ui/packages/KefuCascaderTable/node_modules/@types/mdast/index.d.ts
rpt2:     /Users/bytedance/Public/helpdesk-semi-ui/packages/KefuCascaderTable/node_modules/@types/node/ts3.7/index.d.ts
rpt2:     /Users/bytedance/Public/helpdesk-semi-ui/packages/KefuCascaderTable/node_modules/@types/normalize-package-data/index.d.ts
rpt2:     /Users/bytedance/Public/helpdesk-semi-ui/packages/KefuCascaderTable/node_modules/@types/parse-json/index.d.ts
rpt2:     /Users/bytedance/Public/helpdesk-semi-ui/packages/KefuCascaderTable/node_modules/@types/parse5/index.d.ts
rpt2:     /Users/bytedance/Public/helpdesk-semi-ui/packages/KefuCascaderTable/node_modules/@types/prettier/index.d.ts
rpt2:     /Users/bytedance/Public/helpdesk-semi-ui/packages/KefuCascaderTable/node_modules/@types/prop-types/index.d.ts
rpt2:     /Users/bytedance/Public/helpdesk-semi-ui/packages/KefuCascaderTable/node_modules/@types/q/index.d.ts
rpt2:     /Users/bytedance/Public/helpdesk-semi-ui/packages/KefuCascaderTable/node_modules/@types/react/index.d.ts
rpt2:     /Users/bytedance/Public/helpdesk-semi-ui/packages/KefuCascaderTable/node_modules/@types/react-dom/index.d.ts
rpt2:     /Users/bytedance/Public/helpdesk-semi-ui/packages/KefuCascaderTable/node_modules/@types/resolve/index.d.ts
rpt2:     /Users/bytedance/Public/helpdesk-semi-ui/packages/KefuCascaderTable/node_modules/@types/stack-utils/index.d.ts
rpt2:     /Users/bytedance/Public/helpdesk-semi-ui/packages/KefuCascaderTable/node_modules/@types/unist/index.d.ts
rpt2:     /Users/bytedance/Public/helpdesk-semi-ui/packages/KefuCascaderTable/node_modules/@types/yargs/index.d.ts
rpt2:     /Users/bytedance/Public/helpdesk-semi-ui/packages/KefuCascaderTable/node_modules/@types/yargs-parser/index.d.ts
rpt2:     /Users/bytedance/Public/helpdesk-semi-ui/packages/KefuCascaderTable/node_modules/@types/json-schema/index.d.ts
rpt2:     /Users/bytedance/node_modules/@types/json5/index.d.ts
rpt2:     /Users/bytedance/node_modules/@types/minimist/index.d.ts
rpt2:     /Users/bytedance/Public/helpdesk-semi-ui/packages/KefuCascaderTable/node_modules/@types/node/ts3.7/index.d.ts
rpt2:     /Users/bytedance/Public/helpdesk-semi-ui/packages/KefuCascaderTable/node_modules/@types/normalize-package-data/index.d.ts
rpt2:     /Users/bytedance/Public/helpdesk-semi-ui/packages/KefuCascaderTable/node_modules/@types/parse-json/index.d.ts
rpt2: ambient types changed, redoing all semantic diagnostics
rpt2: transpiling '/Users/bytedance/Public/helpdesk-semi-ui/packages/KefuCascaderTable/src/lib/index.tsx'
rpt2:     cache: '/Users/bytedance/Public/helpdesk-semi-ui/packages/KefuCascaderTable/node_modules/.cache/rollup-plugin-typescript2/rpt2_9e69c65b2d74fee0ad388d42568ea4ce7ba1b27d/code/cache/7cdbf1c7db69c2fd53815824bca49513a129c642'
rpt2:     cache miss
rpt2: generated declarations for '/Users/bytedance/Public/helpdesk-semi-ui/packages/KefuCascaderTable/src/lib/index.tsx'
rpt2: dependency '/Users/bytedance/Public/helpdesk-semi-ui/packages/KefuCascaderTable/src/lib/utils.ts'
rpt2:     imported by '/Users/bytedance/Public/helpdesk-semi-ui/packages/KefuCascaderTable/src/lib/index.tsx'
rpt2: resolving './utils' imported by '/Users/bytedance/Public/helpdesk-semi-ui/packages/KefuCascaderTable/src/lib/index.tsx'
rpt2:     to '/Users/bytedance/Public/helpdesk-semi-ui/packages/KefuCascaderTable/src/lib/utils.ts'
rpt2: dependency '/Users/bytedance/Public/helpdesk-semi-ui/packages/KefuCascaderTable/src/lib/mock.ts'
rpt2:     imported by '/Users/bytedance/Public/helpdesk-semi-ui/packages/KefuCascaderTable/src/lib/index.tsx'
rpt2: resolving './mock' imported by '/Users/bytedance/Public/helpdesk-semi-ui/packages/KefuCascaderTable/src/lib/index.tsx'
rpt2:     to '/Users/bytedance/Public/helpdesk-semi-ui/packages/KefuCascaderTable/src/lib/mock.ts'
rpt2: transpiling '/Users/bytedance/Public/helpdesk-semi-ui/packages/KefuCascaderTable/src/lib/mock.ts'
rpt2:     cache: '/Users/bytedance/Public/helpdesk-semi-ui/packages/KefuCascaderTable/node_modules/.cache/rollup-plugin-typescript2/rpt2_9e69c65b2d74fee0ad388d42568ea4ce7ba1b27d/code/cache/a3be5c51ebb3fef03fc9a43c539d188ad1577216'
rpt2:     cache hit
rpt2: generated declarations for '/Users/bytedance/Public/helpdesk-semi-ui/packages/KefuCascaderTable/src/lib/mock.ts'
rpt2: transpiling '/Users/bytedance/Public/helpdesk-semi-ui/packages/KefuCascaderTable/src/lib/utils.ts'
rpt2:     cache: '/Users/bytedance/Public/helpdesk-semi-ui/packages/KefuCascaderTable/node_modules/.cache/rollup-plugin-typescript2/rpt2_9e69c65b2d74fee0ad388d42568ea4ce7ba1b27d/code/cache/d1d6e9acec5e9e0b4392fcbc5bf623dab081aa31'
rpt2:     cache hit
rpt2: generated declarations for '/Users/bytedance/Public/helpdesk-semi-ui/packages/KefuCascaderTable/src/lib/utils.ts'

rpt2: generating target 1
rpt2: rolling caches
rpt2: emitting declarations for '/Users/bytedance/Public/helpdesk-semi-ui/packages/KefuCascaderTable/src/lib/index.tsx' to '/Users/bytedance/Public/helpdesk-semi-ui/packages/KefuCascaderTable/dist/type/src/lib/index.d.ts'
rpt2: emitting declarations for '/Users/bytedance/Public/helpdesk-semi-ui/packages/KefuCascaderTable/src/lib/mock.ts' to '/Users/bytedance/Public/helpdesk-semi-ui/packages/KefuCascaderTable/dist/type/src/lib/mock.d.ts'
rpt2: emitting declarations for '/Users/bytedance/Public/helpdesk-semi-ui/packages/KefuCascaderTable/src/lib/utils.ts' to '/Users/bytedance/Public/helpdesk-semi-ui/packages/KefuCascaderTable/dist/type/src/lib/utils.d.ts'
(!) Broken sourcemap
https://rollupjs.org/guide/en/#warning-sourcemap-is-likely-to-be-incorrect
Plugins that transform code (such as 'at position 9') should generate accompanying sourcemaps
created dist/index.esm.js in 2.7s

User/dist/type/src/lib/index.d.ts → dist/index.d.ts...
[!] Error: Could not resolve './component' from dist/type/src/lib/index.d.ts
Error: Could not resolve './component' from dist/type/src/lib/index.d.ts
@agilgur5 agilgur5 changed the title rpt2 ignore some files unexpectly some TS files are ignored? Aug 17, 2022
@agilgur5 agilgur5 added problem: removed issue template OP removed the issue template without good cause problem: no repro No reproduction was provided (and have not tried to repro without one) labels Aug 17, 2022
@agilgur5
Copy link
Collaborator

agilgur5 commented Aug 17, 2022

skipped parts of issue template

You didn't answer question 2 and 3 of the issue template, and did not provide a package.json either. Please don't skip pieces of the issue template, they are there for a reason.

Specifically, I noted that there's 9 other plugins and a TS transformer and other complexity here, so it's far from a minimal repro, and a repro itself was not provided. The plugin order also does not match this plugin's compatibility list, and no rationale was given for why either.

rpt2 version

Per the versions listed, you're also on an older version of rpt2, 0.30.0, and not the current 0.32.1.

edge cases seem to not apply

Given the lack of repro, I can only hypothesize why this may occur, as no further investigation is possible without a repro. At the very least the contents of component.ts and the file(s) that import it must be known in order to diagnose.

Without knowing the contents of the files, the only edge-cases in rpt2 are around type-only imports, i.e. #211 (which will soon be fixed by #406). Given that this produces a .js file with tsc, it doesn't seem to be a type-only import. And given that you're not using files anyway, the current workaround mentioned in #211 (comment) should work as well.
So this does not seem to be caused by #211 or related to type-only imports (unless there's a detail I'm missing here)

That's the only existing issue (that has a repro) that I can think of off the top of my head that might cause this kind of problem and it does not seem to be the culprit.

As such, there's really nothing else that can be done without a repro. Please provide a minimal repro as the issue template requests.

EDIT: Per the repro provided below, component.ts is in fact a type-only file. So will have to check why the workaround for #211 isn't working in this case.

@agilgur5 agilgur5 added problem: needs more info This issue needs more information in order to handle it problem: plugin order The plugin order in this issue seems incompatible. See the "Compatibility" section in the README labels Aug 17, 2022
@ZHHHH9980
Copy link
Author

@agilgur5
minimal repro: https://github.com/ZHHHH9980/mini-demo

npm install && npm run build:esm

will get the same error:
image

Hope that will help.

@agilgur5 agilgur5 added topic: type-only / emit-less imports Related to importing type-only files that will not be emitted and removed problem: needs more info This issue needs more information in order to handle it problem: no repro No reproduction was provided (and have not tried to repro without one) labels Aug 18, 2022
@agilgur5
Copy link
Collaborator

repro: https://github.com/ZHHHH9980/mini-demo

Thanks for the repro @ZHHHH9980, this helps quite a bit. Per the repro provided, component.ts is in fact a type-only file.
So this is impacted by #211 and may just be a duplicate of that. Note that #211 has a fix out in #406.

That being said, I'm not sure why the workaround (from #175) isn't working in this case. I'll have to investigate that with the repro. This might be fixable with a simple change to the tsconfig include.

minimal

Just to clarify, the issue template defines "minimal" with the oft-cited StackOverflow explanation.
This is a "repro" but it is not minimal because there are still, as I previously mentioned, many other plugins in use and large files etc that complicate the reproduction.
Per the same line in the issue template, we actually provide a sample environment that we recommend using. That sample env is quite minimal, so a "minimal repro" would add the minimum changes to that in order to exhibit the problematic / buggy behavior.

@agilgur5 agilgur5 added kind: bug Something isn't working properly solution: duplicate This issue or pull request already exists priority: in progress labels Aug 18, 2022
@agilgur5 agilgur5 changed the title some TS files are ignored? some type-only TS files are ignored? Aug 18, 2022
@agilgur5 agilgur5 changed the title some type-only TS files are ignored? some type-only TS files are ignored when using tsconfig files? Aug 18, 2022
@agilgur5
Copy link
Collaborator

duplicate of #211

That being said, I'm not sure why the workaround (from #175) isn't working in this case. I'll have to investigate that with the repro. This might be fixable with a simple change to the tsconfig include.

So your repro has a different tsconfig.json than the one you posted in your opening comment of the issue. In particular you are using tsconfig files. And as component.ts is a type-only file, it doesn't get detected by Rollup.

So this duplicates #211, which will be fixed by #406.

workaround available

That being said, since this is a duplicate and you are using files (i.e. this is not a new issue), the workarounds available will work for your situation as well. This workaround and is simple available right now: add component.ts to your files list

  "files": ["src/lib/index.tsx", "src/lib/component.ts"],

This will get TS to detect the file and rpt2 will generate declarations for it.

That workaround should suffice in the meantime until #406 is reviewed, merged, and released.

@agilgur5 agilgur5 added the solution: workaround available There is a workaround available for this issue label Aug 18, 2022
@agilgur5
Copy link
Collaborator

agilgur5 commented Sep 12, 2022

#406 has been merged and released in 0.34.0.

I also did not get the error you did in your logs when using your repro with 0.34.0 (there's another error, but that's unrelated to rpt2).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
kind: bug Something isn't working properly problem: plugin order The plugin order in this issue seems incompatible. See the "Compatibility" section in the README problem: removed issue template OP removed the issue template without good cause solution: duplicate This issue or pull request already exists solution: workaround available There is a workaround available for this issue topic: type-only / emit-less imports Related to importing type-only files that will not be emitted
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants