Hi! We have the following folder structure:
- project_folder/src contains TypeScript source code
- project_folder/ts_config.json defines
"baseUrl": "src" and paths "~/*": ["./*"]
- project_folder/rollup.config.mjs uses the following configuration:
plugins: [
image(),
json(),
peerDepsExternal(),
resolve(),
commonjs(),
typescript({ tsconfig: './tsconfig.json' }),
terser(),
alias({
entries: {
'~': path.resolve(projectRootDir, './src'),
},
}),
copy({
targets: [{ src: 'src/assets/fonts/*', dest: 'fonts' }],
}),
copy({
targets: [{ src: 'src/assets/icons/*.svg', dest: ['dist/cjs/assets/icons', 'dist/esm/assets/icons'] }],
}),
],
and
plugins: [
image(),
alias({
entries: {
'~': path.resolve(projectRootDir, './src'),
},
}),
dts(),
],
- project_folder/src/components contains all our TypeScript components
Each TypeScript component is exported from components/index.ts.
Now, where is the problem?
There seems to be a problem when a sibling file imports code from another sibling through an absolute import.
Given this folder structure:
src
components
Box
Box.tsx
index.ts
FlexLayout
FlexLayout.tsx
index.ts
When importing for example Box from Box.tsx into FlexLayout.tsx via an absolute import import { BoxProps } from '~/components' will cause problems, while importing directly will not import { BoxProps } from '../Box'. We have no idea why. Also, we are able to both run the project and render the component, but rollup won't work.
This problem does not affect non-sibling file imports.
Any ideas?
Hi! We have the following folder structure:
"baseUrl": "src"and paths"~/*": ["./*"]and
Each TypeScript component is exported from
components/index.ts.Now, where is the problem?
There seems to be a problem when a sibling file imports code from another sibling through an absolute import.
Given this folder structure:
When importing for example Box from
Box.tsxintoFlexLayout.tsxvia an absolute importimport { BoxProps } from '~/components'will cause problems, while importing directly will notimport { BoxProps } from '../Box'. We have no idea why. Also, we are able to both run the project and render the component, butrollupwon't work.This problem does not affect non-sibling file imports.
Any ideas?