Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 0 additions & 11 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,17 +3,6 @@
"version": "1.4.0",
"private": true,
"repository": "https://github.com/typed-ember/glint",
"workspaces": {
"packages": [
"packages/*",
"test-packages/*"
],
"nohoist:comment": "When running extension host in test-packages/ts-plugin-test-app, we need 1. to be able to use workspace TypeScript, and 2. to use a TS Plugin specified as an npm dependency, both which require typescript and the plugin to be present within the same folder's `node_modules` directory.",
"nohoist": [
"ts-plugin-test-app/typescript",
"ts-plugin-test-app/@glint/tsserver-plugin"
]
},
"scripts": {
"build": "tsc --build",
"build:watch": "tsc --build --watch",
Expand Down
23 changes: 22 additions & 1 deletion packages/core/src/transform/template/rewrite-module.ts
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,28 @@ function calculateCorrelatedSpans(
): CorrelatedSpansResult {
let directives: Array<Directive> = [];
let errors: Array<TransformError> = [];
let partialSpans: Array<PartialCorrelatedSpan> = [];
let partialSpans: Array<PartialCorrelatedSpan> = [
// HACK: We prefix every transformed TS file with these non-existent imports
// because it causes TypeScript to consider `.gts` and `.gjs` as possible
// implied extensions when extensions are omitted from import module specifiers,
// i.e. it causes `import FooComponent from './foo';` to work given a `foo.gts` file.
//
// Origin of this hack:
// https://github.com/typed-ember/glint/issues/806#issuecomment-2758616327
//
// Note that these imports WILL generate diagnostic errors, but because they're
// mapped to zero-length source code spans, they're essentially mapped to nothing,
// and when Volar reverse-transforms the diagnostics back to the original source
// code, they'll be discarded.
{
originalFile: script,
originalStart: 0,
originalLength: 0,
insertionPoint: 0,
transformedSource:
"import __GLINT_GTS_EXTENSION_HACK__ from './__glint-non-existent.gts';\n import __GLINT_GJS_EXTENSION_HACK__ from './__glint-non-existent.gjs';\n",
},
];

let { ast, emitMetadata, error } = parseScript(ts, script, environment);

Expand Down
4 changes: 2 additions & 2 deletions packages/vscode/.vscodeignore
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ tsconfig.json
tsconfig.tsbuildinfo

node_modules/**/
!node_modules/glint-tsserver-plugin-pack.js
!node_modules/glint-core-pack.js
!node_modules/glint-tsserver-plugin-pack/index.js
!node_modules/glint-core-pack/index.js

scripts/
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
import Component from '@glimmer/component';
import Greeting from './Greeting.gts';
import Greeting from './Greeting';
import Colocated from './colocated-folder';

export interface OtherSignature {
Args: { target: string };
}
Expand All @@ -9,5 +11,6 @@ export default class Other extends Component<OtherSignature> {

<template>
<Greeting @target="World" />
<Colocated @target="World" />
</template>
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
import Component from '@glimmer/component';

export interface ColocatedIndexSignature {
Args: { target: string };
}

export default class ColocatedIndex extends Component<ColocatedIndexSignature> {
private message = 'Hello';

<template>
{{this.message}}, {{@target}}!
</template>
}

This file was deleted.

This file was deleted.

3 changes: 2 additions & 1 deletion packages/vscode/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
"name": "glint-vscode",
"displayName": "Glint",
"description": "Glint language server integration for VS Code",
"version": "1.4.3",
"version": "1.4.5",
"publisher": "typed-ember",
"private": true,
"author": "James C. Davis (https://github.com/jamescdavis)",
Expand Down Expand Up @@ -257,6 +257,7 @@
"glob": "^10.2.4",
"mocha": "^10.2.0",
"reactive-vscode": "0.2.7-beta.1",
"semver": "^7.5.2",
"typescript": "^5.8.2",
"vscode-ext-gen": "^0.5.0"
},
Expand Down
9 changes: 5 additions & 4 deletions packages/vscode/scripts/build.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -14,23 +14,24 @@ const ctx = await context({
bundle: true,
entryPoints: {
'dist/extension': require.resolve('../lib/src/extension.js'),
'node_modules/glint-tsserver-plugin-pack': '../tsserver-plugin/lib/typescript-server-plugin.js',
'node_modules/glint-core-pack': '../core/lib/index.js',
'node_modules/glint-tsserver-plugin-pack/index':
'../tsserver-plugin/lib/typescript-server-plugin.js',
'node_modules/glint-core-pack/index': '../core/lib/index.js',
},
external: ['vscode'],
logLevel: 'info',
minify: !debug,
outdir: fileURLToPath(new URL('../', import.meta.url)),
platform: 'node',
sourcemap: debug,
sourcemap: false,
target: 'node16',

// Since we're generating CJS, we need to replace any ESM import.meta.url with `__filename`
// https://github.com/evanw/esbuild/issues/1492#issuecomment-893144483
inject: [require.resolve('./import-meta-url.js')],
define: {
'import.meta.url': 'import_meta_url',
GLINT_CORE_PATH: '"glint-core-pack.js"',
GLINT_CORE_PATH: '"glint-core-pack/index.js"',
},

plugins: [
Expand Down
2 changes: 1 addition & 1 deletion packages/vscode/src/generated-meta.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
// Meta info
export const publisher = "typed-ember"
export const name = "glint-vscode"
export const version = "1.4.3"
export const version = "1.4.5"
export const displayName = "Glint"
export const description = "Glint language server integration for VS Code"
export const extensionId = `${publisher}.${name}`
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
import {
teardownSharedTestWorkspaceAfterEach,
requestDiagnostics,
} from 'glint-monorepo-test-utils';
import { describe, afterEach, test, expect } from 'vitest';
import { stripIndent } from 'common-tags';

describe('Language Server: Imports', () => {
afterEach(teardownSharedTestWorkspaceAfterEach);

test('support moduleResolution=bundler index.gts resolution from gts file with <template>', async () => {
const code = stripIndent`
import Colocated from './colocated';

export default <template>
<Colocated @target="World" />
</template>
`;

const diagnostics = await requestDiagnostics(
'ts-template-imports-app/src/ephemeral-index.gts',
'glimmer-ts',
code,
);

expect(diagnostics).toMatchInlineSnapshot(`[]`);
});

test('support moduleResolution=bundler index.gts resolution from gts file with no <template>', async () => {
const code = stripIndent`
import Colocated from './colocated';

export default Colocated;
`;

const diagnostics = await requestDiagnostics(
'ts-template-imports-app/src/ephemeral-index.gts',
'glimmer-ts',
code,
);

expect(diagnostics).toMatchInlineSnapshot(`[]`);
});
});
Loading
Loading