Is it possible to create and use a 100% TypeScript npm package without building to JavaScript?
I tried so and added "main": "index.ts" into package.json but when I import my modules I get:
export * from './lib/my-module';
SyntaxError: Unexpected token 'export'
The reason why I don't want to compile is that it is a private package and will be used in TypeScript projects only. Also I want to keep all decorators and comments as they are but when I tsc they get removed.
Yes, it possible to create a pure typescript package.
"main": "index.ts". index.ts should contain all types/components that should be available outside. For example:export * from './model'
export * from './data-table'
export * from './context'
export * from './external-kit'
source-map-loader in webpack.config.js{
enforce: 'pre',
exclude: /PACKAGE_NAME/,
test: /\.(js|mjs|jsx|ts|tsx|css)$/,
loader: require.resolve('source-map-loader'),
}
{
test: /\.(js|mjs|jsx|ts|tsx)$/,
include: [paths.appSrc, path.resolve(appDirectory, 'node_modules/PACKAGE_NAME')],
loader: require.resolve('babel-loader'),
...
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With