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

Support TypeScript without ember-cli-typescript #1236

Merged
merged 4 commits into from
Aug 20, 2022

Conversation

NullVoxPopuli
Copy link
Collaborator

@NullVoxPopuli NullVoxPopuli commented Jul 27, 2022

Repro'd and then patched here: NullVoxPopuli/ember-demo-typescript-without-ec-ts@dd5baa6

With glint + <template>, ember-cli-typescript's type-checking worker is incorrect as tsserver can't, by itself, resolve .gts imports.

Since glint projects fully manage type checking within glint (and gts transformation via ember-template-imports), ember-cli-typescript should be removed as a requirement for projects using typescript so that we can reduce terminal noise in the build.

Later, we may bundle glint in some webpack (or preferrably, unplugin) plugin such that we properly type check ember projects with glint / template-imports (maybe similar to fork-ts-checker--webpack-plugin )

anywho, this PR is mostly tests:

  • additional app template, based off of the ember-cli-typescript blueprint
    but also
    • some simplifications of the tsconfig.json
    • convert app.js, router.js, and test-helper.js to ts to have a minimal set of "ts stuff" for every test/scenario

Resolves: #889

@NullVoxPopuli NullVoxPopuli force-pushed the ts-without-ec-ts branch 4 times, most recently from 28c0445 to f46fcae Compare July 27, 2022 02:35
@NullVoxPopuli
Copy link
Collaborator Author

NullVoxPopuli commented Jul 27, 2022

I probably broke something 😅

Build Error (PackagerRunner) in assets/test.js

Module build failed (from ../../../../../..<repo>/tests/scenarios/output/node_modules/@embroider/webpack/node_modules/thread-loader/dist/cjs.js):
Thread Loader (Worker 1)
[BABEL] $TMPDIR/embroider/d9b711/tests/scenarios/output/assets/test.js/test.js: module.call is not a function (While processing: "<repo>/packages/core/src/portable-babel-launcher.js")

    at babelLauncher (<repo>/packages/core/src/portable-babel-launcher.js:18:25)}

@NullVoxPopuli NullVoxPopuli force-pushed the ts-without-ec-ts branch 2 times, most recently from 5f7762b to 6cee7fe Compare July 28, 2022 18:43
@NullVoxPopuli NullVoxPopuli marked this pull request as ready for review August 18, 2022 20:27
@ef4 ef4 merged commit be31c12 into embroider-build:main Aug 20, 2022
// For TS, we defer to ember-cli-babel, and the setting for
// "enableTypescriptTransform" can be set with and without
// ember-cli-typescript
return ['.wasm', '.mjs', '.js', '.json', '.hbs', '.ts'];

Choose a reason for hiding this comment

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

This introduces a bug that causes TypeScript component files to be ignored when staticComponents: true

should be: return ['.ts', '.wasm', '.mjs', '.js', '.json', '.hbs'];

Copy link
Collaborator Author

@NullVoxPopuli NullVoxPopuli Oct 8, 2022

Choose a reason for hiding this comment

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

how does that happen / how does moving ts to the front resolve it? 🤔

Copy link

@bwbuchanan bwbuchanan Oct 8, 2022

Choose a reason for hiding this comment

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

I'm not at all familiar with the internals of embroider and had to diagnose this by trial-and-error.

The previous version of the code unshifts '.ts' onto the array (placing it at the front). This change moves it to the end of the array.

When I inspected $TMPDIR/embroider/.../components, I found three files for each of my TypeScript components: .hbs, .js, and .ts.

.hbs and .ts were as expected. .js contains a templateOnlyComponent stub.

I can only deduce that in the process of assembling the app, embroider looks for the component implementation file in the order of the extensions in this array, so moving .ts to the end of the array means that it finds the empty stub implementation and ignores the actual implementation in the .ts file.

I have no idea why the stub .js implementations are being generated if a .ts backing class definition exists. Perhaps this is a different bug, or perhaps intended behavior?

The result is a broken component with no backing class.

Doesn't happen if staticComponents = false in the embroider config.

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.

Bug: No TypeScript support (without ember-cli-typescript)
3 participants