parcel-bundler / parcel

The zero configuration build tool for the web. 📦🚀
https://parceljs.org
MIT License
43.46k stars 2.27k forks source link

Export of parcel's implicit/internal configs e.g. tsconfig.json #1774

Open raould opened 6 years ago

raould commented 6 years ago

🙋 feature request

I am trying to learn Typescript. I am getting errors when I reload my page that uses typescript, and I need to figure out what is going on. I think I am using standard Typescript syntax. Thus I want to be able to test what parcel is doing vs. what tsc would do. But in order to compare apples to apples, I need the tsconfig.json (and anything else relevant) that parcel uses to do the magic zero config work of converting my .ts files.

Note: If I were doing some other packaging stuff that was magically being zero conf'd for me by parcel, I'd want a way to get those internal/implicit config files emitted as well. This isn't only for typescript, it is for helping mere mortals who are trying to learn, debug, deal with the "magic" that can sometimes be "too much magic".)

🤔 Expected Behavior

I guess there should be another cli command like "export-configs" which would cause the config files to be emitted, maybe into the dist/ folder by default. Or something, I dunno exactly what makes the most sense since I am a newb with all this.

😯 Current Behavior

I do not see a way to manually duplicate what parcel is doing with my typescript project, so I cannot try to manually run the pipeline and see if I can figure out if/where any bug might be.

💁 Possible Solution

🔦 Context

When I get errors in the Firefox dev console from reloading, like this one below, I want to be able to figure out what the problem is. Ie how can I dis/prove that parcel is screwing up vs. me doing it wrong since I don't really know ts or parcel at all well yet.

ReferenceError: wwidth is not defined[Learn More] K.ts:2:8
parcelRequire<["src\\K.ts"]<
K.ts:2:8
newRequire
http://localhost:1234/src.2fbc20e7.js:48:7
localRequire
http://localhost:1234/src.2fbc20e7.js:54:14
parcelRequire<["src\\index.ts"]<
index.ts:3
newRequire
http://localhost:1234/src.2fbc20e7.js:48:7
parcelRequire<
http://localhost:1234/src.2fbc20e7.js:80:5
<anonymous>
http://localhost:1234/src.2fbc20e7.js:10:18

💻 Examples

tmp.zip

raould commented 6 years ago

I think the feature I described above would still be good - but here's what I did at the moment...

Okay I used "tsc --init" and munged it to be what is here below, and that helped me find my syntax error! Yay! And then the page works via parcel.

{
  "compilerOptions": {
    "target": "es5",
    "module": "none",
    "strict": true,
    "esModuleInterop": true,
  },
  "include": [
      "src/**/*"
  ],
  "exclude": [
      "node_modules"
  ]
}

(so... €0.02 I think the default behaviour of parcel not showing typescript errors is really weird! Either it should really support typescript out of the box (what is typescript w/out type checking?!) or the docs should not claim that it is a "just working"/"zero config" thing because it is not a real typescript solution in my humble opine.)

fathyb commented 6 years ago

I think the default behaviour of parcel not showing typescript errors is really weird

Most people don't want to type-check, so you need to use the parcel-plugin-typescript to get type-checking. It's also pretty expensive to type-check given that TypeScript is almost turing complete at compile-time and goes against the current Parcel concurrency model, so we need weird IPC/worker system + parallel transpiling. It's just better to disable it by default and let power-users enable it when needed. You also need the plugin for stuff like const enum and paths/baseUrl.

what is typescript w/out type checking

A coffee brewer used to make hot water 🙃

raould commented 6 years ago

Qq why 'closed'? The sugested feature is still relevant I believe for parcel in general. (Don't get confused about my ad hominim about coffee makers. :-)

fathyb commented 6 years ago

I'm sorry, I thought the issue was resolved and went trigger happy.

So if I understand you'd like to get TypeScript Parcel default tsconfig.json settings? By default Parcel uses this (see src/assets/TypeScriptAsset.js) :

{
  "compilerOptions": {
    "module": "commonjs",
    "jsx": "preserve",
    "esModuleInterop": true,

    // false if source maps are disabled
    "sourceMaps": true,
    "noEmit": false
  }
}

Given it's always the same maybe we should put in the website docs?

raould commented 6 years ago

yeah, but at a high level, i always want to be able to peek under the hood for educational but more seriously for debugging & sanity checking purposes. So the dream feature is to have parcel export a stand-alone complete set of configs that would build my project exactly the same way, only without parcel. In this case it would at least be the tsconfig.json but then might also include whatever packager is used under the covers.