isaacs / tshy

Other
886 stars 18 forks source link

liveDev bug? #74

Closed jrnail23 closed 5 months ago

jrnail23 commented 5 months ago

I was just taking liveDev for a spin, and I may have found a bug. Without liveDev, my config with "exports": "./src/**" generates the following exports:

{
  "exports": {
    "./feature-flagging": {
      "import": {
        "types": "./dist/esm/feature-flagging.d.ts",
        "source": "./src/feature-flagging.ts",
        "default": "./dist/esm/feature-flagging.js"
      },
      "require": {
        "types": "./dist/commonjs/feature-flagging.d.ts",
        "source": "./src/feature-flagging.ts",
        "default": "./dist/commonjs/feature-flagging.js"
      }
    },
    ".": {
      "import": {
        "types": "./dist/esm/index.d.ts",
        "source": "./src/index.ts",
        "default": "./dist/esm/index.js"
      },
      "require": {
        "types": "./dist/commonjs/index.d.ts",
        "source": "./src/index.ts",
        "default": "./dist/commonjs/index.js"
      }
    },
  }
}

while with liveDev: true, it generates this (note the .ts extensions on the default mappings):

{
  "exports": {
    "./feature-flagging": {
      "import": {
        "source": "./src/feature-flagging.ts",
        "default": "./dist/esm/feature-flagging.ts"
      },
      "require": {
        "source": "./src/feature-flagging.ts",
        "default": "./dist/commonjs/feature-flagging.ts"
      }
    },
    ".": {
      "import": {
        "source": "./src/index.ts",
        "default": "./dist/esm/index.ts"
      },
      "require": {
        "source": "./src/index.ts",
        "default": "./dist/commonjs/index.ts"
      }
    },
  }
}

Shouldn't those paths from the /dist/ dir each have .js extensions?

isaacs commented 5 months ago

No, actually, that's the point of liveDev. It hard-links the source files with their .ts extensions rather than building with tsc. So you just have source and default.

The intention is to use it only in development, with an editor and test runner that can handle typescript directly.