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

Resolve config from extends package #781

Merged

Conversation

iarroyo
Copy link
Contributor

@iarroyo iarroyo commented Dec 18, 2024

Resolve glint configuration when your tsconfig.json extends from a package, ex

path: tsconfig.json

{
  "extends": "@package1"
}

path: node_modules/@package1/tsconfig.json

{
  "glint": {
    "environment": ["ember-loose", "ember-template-imports"]
  }
}

Note: I'm uncertain if this is the correct branch to merge with. If it isn't, please let me know.

import SilentError from 'silent-error';
import { GlintConfig } from './config.js';
import { GlintConfigInput } from '@glint/core/config-types';
import type * as TS from 'typescript';

const require = createRequire(import.meta.url);
export const require = createRequire(import.meta.url);
Copy link
Contributor

Choose a reason for hiding this comment

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

why export this?
conventionally, we really only want to use createRequire in the file it's used in, since the resolution rules are specific to the import.meta.url

Copy link
Contributor

Choose a reason for hiding this comment

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

ah, it's for mocking in tests.

can you add a block-comment with something like:

/**
 * @private 
 *
 * Only exported for testing purposes. Do not import.
 */

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Done

JSON.stringify({
extends: '@package1/tsconfig.json',
glint: {
environment: '../local-env',
Copy link
Contributor

Choose a reason for hiding this comment

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

what's local-env?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

To be honest, I simply followed the example from the previous test which uses a predefined environment in the beforeEach

Copy link
Contributor

@NullVoxPopuli NullVoxPopuli left a comment

Choose a reason for hiding this comment

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

This is looking good -- left some questions.
Also, would you be willing to PR this to the main branch as well?

@iarroyo
Copy link
Contributor Author

iarroyo commented Dec 28, 2024

This is looking good -- left some questions. Also, would you be willing to PR this to the main branch as well?

Definitely, I will create a PR against the main branch

@iarroyo
Copy link
Contributor Author

iarroyo commented Dec 28, 2024

PR Created
#782

@iarroyo
Copy link
Contributor Author

iarroyo commented Jan 7, 2025

@NullVoxPopuli @wagenet
I am not sure why those CI / Test are failing but I noticed it also happen in the last tag 1.5.0
My previous conclusion was wrong, PR updated.

It looks like the two jobs that didn't go so well also had problems in the 1.5.0 release.

try {
currentPath = require.resolve(currentContents.extends);
} catch (error) {
// control the exception, do nothing.
Copy link
Contributor

Choose a reason for hiding this comment

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

Should we log the error?
Or log some message? Could be goofy to debug otherwise?

What's the error thrown here?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

If I log anything this test and others will fail

Please refer to the image below that shows the error being displayed.
Screenshot 2025-01-08 at 15 34 49

Copy link
Contributor

Choose a reason for hiding this comment

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

ahh ok. thanks!

@NullVoxPopuli NullVoxPopuli added the bug Something isn't working label Jan 8, 2025
@NullVoxPopuli
Copy link
Contributor

thanks for this! do you want to make the same changes on main as well?

@NullVoxPopuli NullVoxPopuli merged commit 408074c into typed-ember:v1.x Jan 8, 2025
2 of 4 checks passed
@iarroyo
Copy link
Contributor Author

iarroyo commented Jan 8, 2025

thanks for this! do you want to make the same changes on main as well?

Yep, let's make sure that the exception is not propagated.
I´ll add a try/catch

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants