-
-
Notifications
You must be signed in to change notification settings - Fork 76
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Could not load source file "../src/Typesense.ts" in source map of "node_modules/typesense/lib/Typesense.js" #86
Comments
Any thoughts on this? The |
I'll take a peek at it when I can, but an extra set of eyes is welcome as I'm unfamiliar with parcel. It appears it's trying to package source maps as part of the build pipeline. Professionally speaking, you should only publish artifacts such as the dist or lib folder with the *.d.ts files (type definitions) and compiled *.js files, not src files. On a practical level, though, you'll find plenty of packages with src folders published. EDIT: One last thought I had after posting this. It's possible we are publishing development builds when we should be publishing production builds to the npm repo. I'd have to look into how we are building the library, but there shouldn't be any reference to source maps in the package at all. |
EDIT: Also disclaimer, I am not familiar with Parcel either. However, I don't think this issue is particular to it. I think @dcantu476 is definitely right. Looks like this library is publishing You can see inside {
"version":3,
"file":"Typesense.js",
"sourceRoot":"",
"sources":["../src/Typesense.ts"],
"names":[],
"mappings":"...<omitted>..."
} Any compiler/interpreter/debugger/whatever reading this file will look for the path(s) at the I think for release, this library needs to be configured with different options so that the TS compiler doesn't generate A production/release TS config file (maybe named "tsconfig.prod.json") might look like this: {
"extends": "./tsconfig",
"compilerOptions": {
"sourceMap": false
}
} Then you'd have to build using this new config before publishing a new version to the package repository. Be careful, I don't think that Hope that explanation wasn't confusing 😅 |
Thank you for the detailed explanation Damian and Aadam! IIRC, I might have explicitly turned on source maps several years ago because I found it helpful to debug and get to the bottom of bugs quickly, when I used the library myself in other projects. The source maps are generated as separate files though, so they don't end up getting including in users' production builds (or at least that was my understanding of how it works). Is it not standard for libraries to bundle source maps (as separate files) in NPM packages this way? If not, if users of the library wanted to report bugs they see, wouldn't it be hard to get stack traces without source maps? |
Found this interesting discussion: googleapis/google-cloud-node#2867 I'm now wondering if we should just publish the |
I've added the src folder for now. |
EDIT: Never mind it was my mistake. I made a bad import import { CollectionCreateSchema } from 'typesense/src/Typesense/Collections'; whereas it should be import { CollectionCreateSchema } from 'typesense/lib/Typesense/Collections'; I leave my senseless blabber below. I don't know how I managed to include it from source. I guess it wasn't intended for these types to be used outside of the package, but I really want my project to be strongly typed where it matters, but then I have to stumble upon foot guns like these. It can be nice that the source is included with source maps, no doubt, but I don't think this was meant to be done, and so Typescript was designed so that you only publish
Or maybe I just didn't set up my {
"compilerOptions": {
"strict": true,
"module": "commonjs",
"moduleResolution": "Node",
"lib": ["es2021"],
"declaration": true,
"removeComments": true,
"emitDecoratorMetadata": true,
"experimentalDecorators": true,
"allowSyntheticDefaultImports": true,
"target": "es2017",
"sourceMap": true,
"outDir": "./dist",
"baseUrl": "./",
"incremental": true,
"skipLibCheck": true
},
"exclude": ["./node_modules"]
} I really don't know what other option I can add to ignore |
The presence of the
I'm not sure why these |
Description
Running
parcel build
shows these warnings:Steps to reproduce
yarn install
parcel build
Expected Behavior
No warnings are logged
Actual Behavior
The warnings above are logged
Metadata
Typsense.js Version: 1.0.3-2
The text was updated successfully, but these errors were encountered: