Skip to content
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

Set target to es2019 in default tsconfig.json #772

Merged
merged 1 commit into from
Mar 31, 2021
Merged

Set target to es2019 in default tsconfig.json #772

merged 1 commit into from
Mar 31, 2021

Conversation

benmccann
Copy link
Member

Should at least make it 2020. Someone on Discord ran into an issue with it being an older version

I hadn't set it in jsconfig.json because that file is pretty minimal and doesn't have any of the other tsconfig.json contents. I'm not sure which settings go in both vs just one or the other

Copy link
Member

@GrygrFlzr GrygrFlzr left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just tested, looks like jsconfig doesn't need it, yeah.

@dummdidumm
Copy link
Member

Jsconfig doesn't need it because it's not used for bundling afaik. For tsconfig that's a different story though. Which problem was it? My fear is that transformations from ts to js might leave stuff in that is too new for anything besides Chrome.

@GrygrFlzr
Copy link
Member

Vite can further transform the output though, can't it? There's even plugins to do ES5, if I remember correctly. TS -> JS is not the final output, I think?

@dummdidumm
Copy link
Member

Honestly I don't know 😄 all I know for sure is that this setting will produce different output for the generated code inside Svelte script tags, because the preprocessors use the tsconfig. If it gets downleveld afterwards (js->older js) I don't know.

@GrygrFlzr
Copy link
Member

We also need to update .eslintrc.cjs to use parserOptions.ecmaVersion 2020 or it'll complain on linting:

  7:17  error  Parsing error: Unexpected token import

 1 problem (1 error, 0 warnings)

@Conduitry
Copy link
Member

@lukeed might have something to say about this. I believe there was a reason we're targeting this version, and it may have to do with what's available in current lambda environments.

@GrygrFlzr
Copy link
Member

Of the existing adapters, Vercel and Netlify has access to Node 14, and Begin has Node 12. Cloudflare Workers is running some version of v8.

If you are targeting Node.js 12.9.0 or newer, you can simply specify "lib": ["es2020"] as that version supports all new functions and properties introduced in ES2020. It doesn't support the new JavaScript syntax though, so you still have to stay on "target": "es2019".

- Linus Unnebäck from stackoverflow

We're targeting 12.17+ due to ESM, so looks like we can instead do:

{
  "compilerOptions": {
    "moduleResolution": "node",
    "lib": ["es2020"],
    "target": "es2019",

That said I ironically cannot replicate import.meta.glob / import.meta.env being an issue on the TypeScript template, and can only make it fail on ESLint on the JS template.

@lukeed
Copy link
Member

lukeed commented Mar 30, 2021

I think es2019 is the latest value you can use while still working in most places. Something like ?? is left as-is with esnext, but that breaks in Node 14.x runtimes.

@benmccann benmccann changed the title Set target to ESNext in default tsconfig.json Set target to es2019 in default tsconfig.json Mar 30, 2021
@benmccann benmccann force-pushed the esnext branch 2 times, most recently from e7c46c0 to 334a4f7 Compare March 30, 2021 15:45
@benmccann
Copy link
Member Author

ok, i've bumped it to 2019 for now

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants