Open Ponjimon opened 4 years ago
Can you provide a minimal reproduction? Can't say what's going on otherwise.
There is a different code-path where it could be hit, but it's highly unlikely a user has it as you'd need to have a src/src/
directory structure, which would be very confusing usage.
@agilgur5 Just happened to me:
yarn
to install the dependenciesyarn build
@gustavopch thanks for the repro. Very weird, it is indeed creating a dist/src/
directory even though you don't have a src/src/
directory. There are no other directories created either, so doesn't seem like you're importing from another directory. 🤔
The check is here, which is inside a deprecated function that moves type declarations from dist/src/
to just dist/
:
https://github.com/formium/tsdx/blob/f0963cb2d77f00bcd8606f8e4b99250972d81b02/src/deprecated.ts#L13-L21
I'm pretty confused as to why that's happening, maybe related to new TS version you're using. However, I was able to workaround the issue by using "files": ["./src/index.ts"]
instead of the "include": ["./src"]
You can also use "include": ["./src/*"]
which seems to work fine as well.
@agilgur5 Wont' that cause some undesired side-effect like ignoring any files that are not placed directly in the src
folder?
Well you already had src
, src/*
isn't really any different except that it avoids this error. Using files
means only things that are actually imported are compiled, which is even better.
It's also in your tsconfig.build.json
and you only want to include src
when building. If you include files that aren't in src
, TS will type-check, compile, and create declarations for those files too. In the past that has meant erroneously adding tests' or examples' declarations into dist
, which shouldn't be there as library users don't use those (and that causes bloating as well as potential side-effects due to how TS merges declarations)
@agilgur5 Unfortunately, dist/application/definitions
is not generated when I apply that workaround. Without the ./src/*
workaround, it's generated.
so no fix for this issue yet rt, cause the work around is not working
Hi,
I am also getting this error when I start a project using pnpm run start
here is my tsconfig.json
{ "include": ["src"], "compilerOptions": { "module": "esnext", "lib": ["dom", "esnext"], "importHelpers": true, "declaration": true, "sourceMap": true, "baseUrl": "src", "strict": true, "noImplicitReturns": true, "noFallthroughCasesInSwitch": true, "noUnusedLocals": true, "noUnusedParameters": true, "moduleResolution": "node", "jsx": "react", "esModuleInterop": true, "skipLibCheck": true, "forceConsistentCasingInFileNames": true, "noEmit": true, "resolveJsonModule": true, "noImplicitAny": false } }
here is my tsdx.config.json
const copy = require('rollup-plugin-copy'); const replace = require('@rollup/plugin-replace');
module.exports = { rollup(config, opts) { config.plugins = config.plugins.map((p) => p.name === 'replace' ? replace({ 'process.env.NODE_ENV': JSON.stringify(opts.env), preventAssignment: true, }) : p );
config.plugins.push(
copy({
targets: [{ src: 'src/*.d.ts', dest: 'dist/' }],
})
);
return config;
}, }
Current Behavior
It complains that
rootDir
is set to./
when it's notExpected behavior
It should not complain about it since
rootDir
is correctly set to./src
Additional context
tsconfig.json:
Your environment