{"id":793,"hash":"3cf1c3a8efde6cc83fbac468a77c40aad241d76eb9ce50d53f5854716905a98e","pattern":"Rollup + Typescript error when importing files outside baseUrl","full_message":"I put together a rollup build system that takes a folder of Typescript components exports them as modules. \n\nThe build system works perfectly if the component files live within the folder structure:\n\nsrc/components/Button\n\nbut the problem arises when I try to import them from outside the baseUrl meaning:\n\n../../javascript/components/Button\n\nAs soon as I try this I get the following errors:\n\n[!] Error: The keyword 'interface' is reserved\n\nThis is what my tsconfig file looks like:\n\n\r\n\r\n{\r\n    \"compilerOptions\": {\r\n        \"jsx\": \"react\",\r\n        \"module\": \"es2015\",\r\n        \"target\": \"es2017\",\r\n        \"moduleResolution\": \"node\",\r\n        \"noImplicitAny\": true,\r\n        \"noImplicitReturns\": true,\r\n        \"noImplicitThis\": true,\r\n        \"noUnusedLocals\": true,\r\n        \"strictNullChecks\": true,\r\n        \"sourceMap\": true,\r\n        \"baseUrl\": \".\",\r\n        \"preserveSymlinks\": true,\r\n        \"esModuleInterop\": true,\r\n        \"paths\": {\r\n            \"ui\": [\"../../components\"]\r\n        }\r\n    },\r\n    \"include\": [\"src/**/*.tsx\"],\r\n    \"exclude\": [\"node_modules\"]\r\n}\r\n\r\n\r\n\nand my rollup.config\n\n\r\n\r\nimport typescript from 'rollup-plugin-typescript2';\r\nimport resolve from 'rollup-plugin-node-resolve';\r\nimport commonjs from 'rollup-plugin-commonjs';\r\nimport less from 'rollup-plugin-less';\r\nimport alias from 'rollup-plugin-alias';\r\n\r\nconst plugins = [\r\n    alias({\r\n        ui: '../../components',\r\n        resolve: ['.tsx', '.ts', '.less']\r\n    }),\r\n    resolve(),\r\n    commonjs({\r\n        // All of our own sources will be ES6 modules, so only node_modules need to be resolved with cjs\r\n        include: 'node_modules/**',\r\n        namedExports: {\r\n            'node_modules/react/index.js': [\r\n                'Component',\r\n                'PropTypes',\r\n                'createElement'\r\n            ],\r\n            'node_modules/lodash/lodash.js': ['isEmpty', 'isString']\r\n        }\r\n    }),\r\n    less({ insert: 'true' }),\r\n    typescript()\r\n];\r\n\r\nexport default {\r\n    plugins,\r\n    external: ['react'],\r\n    input: './src/main.js',\r\n    output: {\r\n        sourcemap: true,\r\n        file: './lib/index.js',\r\n        format: 'cjs'\r\n    }\r\n};\r\n\r\n\r\n\nThanks so much in advance!!!","ecosystem":"npm","package_name":"typescript","package_version":null,"solution":"After investigating for a while, I found that @rollup/plugin-typescript only transform files inside of project root by default. To override that behavior, you need to specify in the include option of the plugin, the globs for the files you plan to use, including the files inside of your project.\n\n\r\n\r\nimport ...\r\n\r\n\r\nconst plugins = [\r\n    /* ... */\r\n    typescript({\r\n      include: [\r\n        // Project files\r\n        './**/*.ts+(|x)',\r\n        // Files from outside of the project\r\n        '../../javascript/**/*.ts+(|x)'\r\n      ]\r\n    })\r\n];\r\n\r\nexport default {\r\n    /* ... */\r\n};\r\n\r\n\r\n\nYou will also need to do this in your 'tsconfig.json', because the plugin will complain that the external files are not listed in your tsconfig.","confidence":0.95,"source":"stackoverflow","source_url":"https://stackoverflow.com/questions/51975831/rollup-typescript-error-when-importing-files-outside-baseurl","votes":8,"created_at":"2026-04-19T04:51:43.008108+00:00","updated_at":"2026-04-19T04:51:43.008108+00:00"}