Skip to content

Having issue with svelte-package #9118

@Ddupasquier

Description

@Ddupasquier

Updates:

index.d.ts now being created/newError

Describe the bug

When running "npm run package", I get this error:

mysvelte-ui lint results:
Errors:
1. pkg.exports["."].types is ./dist/index.d.ts but the file does not exist.
2. pkg.types is ./dist/index.d.ts but the file does not exist.

For some reason the package script isn't generating my ts properly and I'm having an impossible time debugging it.

Here is what my package.json looks like:

"files": [
    "dist/index.js",
    "dist/buttons",
    "dist/inputs"
  ],
  "scripts": {
    "dev": "vite dev",
    "build": "vite build && npm run package",
    "preview": "vite preview",
    "package": "svelte-kit sync && svelte-package && publint",
    "prepublishOnly": "npm run package && publint",
    "test": "playwright test",
    "check": "svelte-kit sync && svelte-check --tsconfig ./tsconfig.json",
    "check:watch": "svelte-kit sync && svelte-check --tsconfig ./tsconfig.json --watch",
    "test:unit": "vitest",
    "lint": "prettier --plugin-search-dir . --check . && eslint .",
    "format": "prettier --plugin-search-dir . --write ."
  },
  "exports": {
    ".": {
      "types": "./dist/index.d.ts",
      "svelte": "./dist/index.js"
    }
  },
  "peerDependencies": {
    "svelte": "^3.54.0"
  },
  "svelte": "./dist/index.js",
  "types": "./dist/index.d.ts",
  "devDependencies": {
    "@fontsource/fira-mono": "^4.5.10",
    "@neoconfetti/svelte": "^1.0.0",
    "@sveltejs/adapter-auto": "^2.0.0",
    "@sveltejs/kit": "^1.5.0",
    "@sveltejs/package": "^2.0.1",
    "@types/cookie": "^0.5.1",
    "@typescript-eslint/eslint-plugin": "^5.45.0",
    "@typescript-eslint/parser": "^5.45.0",
    "eslint": "^8.28.0",
    "eslint-plugin-svelte3": "^4.0.0",
    "svelte-check": "^3.0.1",
    "svelte-highlight": "^7.2.0",
    "publint": "^0.1.9",
    "svelte": "^3.54.0",
    "tslib": "^2.4.1",
    "typescript": "^4.9.3",
    "vite": "^4.0.0"
  },
  "dependencies": {
    "mysvelte-ui": "^0.0.11",
    "sass": "^1.58.1"
  },
  "type": "module"
}

Not entirely sure how relevant it is, but I've also included some pictures of my current file structure, as well as my dist content.
image
image
image

Here is the link to my repo. https://github.com/Ddupasquier/mysvelte_ui

This error can easily be reproduced by running the build script.

Reproduction

Unfortunately I cannot think of a way to reproduce this on a smaller scale.
You'll see the error at the end of the build script.
https://github.com/Ddupasquier/mysvelte_ui/tree/4438db330a094619d33c0d927638eab19572e49c

Logs

> mysvelte-ui@0.0.12 package
> svelte-kit sync && svelte-package && publint


src/lib -> dist
mysvelte-ui lint results:
Errors:
1. pkg.exports["."].types is ./dist/index.d.ts but the file does not exist.
2. pkg.types is ./dist/index.d.ts but the file does not exist.

This is what I get in the logs while running npm publish:

20 verbose title npm publish
21 verbose argv "publish"
22 timing npm:load:setTitle Completed in 1ms
23 timing config:load:flatten Completed in 2ms
24 timing npm:load:display Completed in 2ms
25 verbose logfile logs-max:10 dir:/home/ddupasquier/.npm/_logs/2023-02-18T23_52_11_476Z-
26 verbose logfile /home/ddupasquier/.npm/_logs/2023-02-18T23_52_11_476Z-debug-0.log
27 timing npm:load:logFile Completed in 4ms
28 timing npm:load:timers Completed in 0ms
29 timing npm:load:configScope Completed in 0ms
30 timing npm:load Completed in 22ms
31 verbose publish [ '.' ]
32 silly logfile start cleaning logs, removing 1 files
33 silly logfile done cleaning log files
34 timing command:publish Completed in 3920ms
35 verbose stack Error: command failed
35 verbose stack     at ChildProcess.<anonymous> (/home/ddupasquier/.nvm/versions/node/v18.12.1/lib/node_modules/npm/node_modules/@npmcli/promise-spawn/lib/index.js:53:27)
35 verbose stack     at ChildProcess.emit (node:events:513:28)
35 verbose stack     at maybeClose (node:internal/child_process:1091:16)
35 verbose stack     at ChildProcess._handle.onexit (node:internal/child_process:302:5)
36 verbose pkgid mysvelte-ui@0.0.12
37 verbose cwd /home/ddupasquier/mysvelte_ui
38 verbose Linux 5.10.16.3-microsoft-standard-WSL2
39 verbose node v18.12.1
40 verbose npm  v9.5.0
41 error code 1
42 error path /home/ddupasquier/mysvelte_ui
43 error command failed
44 error command sh -c npm run package && publint
45 verbose exit 1
46 timing npm Completed in 4005ms
47 verbose code 1
48 error A complete log of this run can be found in:
48 error     /home/ddupasquier/.npm/_logs/2023-02-18T23_52_11_476Z-debug-0.log

System Info

System:
    OS: Linux 5.10 Ubuntu 20.04.4 LTS (Focal Fossa)
    CPU: (12) x64 AMD Ryzen 5 5500U with Radeon Graphics
    Memory: 835.16 MB / 3.54 GB
    Container: Yes
    Shell: 5.0.17 - /bin/bash
  Binaries:
    Node: 18.12.1 - ~/.nvm/versions/node/v18.12.1/bin/node
    Yarn: 1.22.19 - /usr/local/bin/yarn
    npm: 9.5.0 - ~/.nvm/versions/node/v18.12.1/bin/npm
  npmPackages:
    @sveltejs/adapter-auto: ^2.0.0 => 2.0.0 
    @sveltejs/kit: ^1.5.0 => 1.5.6 
    @sveltejs/package: ^2.0.1 => 2.0.1 
    svelte: ^3.54.0 => 3.55.1 
    vite: ^4.0.0 => 4.1.1

Severity

serious, but I can work around it

Additional Information

Sorry if this is lacking any crucial information. I'll be readily available to provide anything else needed.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions