Within my Vue project for the company, I have integrated UI helpers from a private npm package that I crafted myself.
For example:
import { UIPosition } from '@mycompany/ui-library'
Yet, whenever I execute a build or serve command for my Vue application (using either vue-cli-service build
or vue-cli-service serve
script), warnings flood the command line interface:
A notice regarding declaration files is displayed (with warnings pertaining to all *.d.ts files in my private package but not for any other packages within node_modules
):
warning in ./node_modules/@mycompany/ui-library/library/utils/UIPosition.d.ts
Module build failed (from ./node_modules/ts-loader/index.js):
Error: Debug Failure. Output generation failed
at Object.transpileModule (/myapp/node_modules/typescript/lib/typescript.js:116864:29)
at getTranspilationEmit (/myapp/node_modules/ts-loader/dist/index.js:318:74)
at successLoader (/myapp/node_modules/ts-loader/dist/index.js:66:15)
at Object.loader (/myapp/node_modules/ts-loader/dist/index.js:22:12)
Furthermore, a warning about map files arises (solely for source maps within my private package and not for other projects located in node_modules
):
warning in ./node_modules/@mycompany/ui-library/index.js.map
Module parse failed: Unexpected token (1:10)
You may need an appropriate loader to handle this file type, currently no loaders are configured to process this file. See https://webpack.js.org/concepts#loaders
> {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA,OAAO;AACP,OAAO,..."}
The @mycompany/ui-library
private package was created by me, allowing for necessary modifications. Despite researching various articles and forums, the optimal setup for private packages remains unknown.
In light of these discoveries, several inquiries arise:
- When integrating a private package, should it automatically detect and compile both declaration (.d.ts) files and map (.js.map) files as indicated by the aforementioned warnings?
- Is there a way to exclude these files as compilation inputs in my project configuration?
- Upon creating a private package, should I export both source map and declaration files? (Evidence suggests these should indeed be exported since declaration files are witnessed in popular projects within
node_modules
, facilitating type inference for individuals working with the packages in their respective IDEs.)