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
1 change: 1 addition & 0 deletions ember-container-query/.eslintignore
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
/blueprints/*/files/

# compiled output
/declarations/
/dist/

# misc
Expand Down
1 change: 1 addition & 0 deletions ember-container-query/.gitignore
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
# compiled output
/declarations/
/dist/

# dependencies
Expand Down
21 changes: 15 additions & 6 deletions ember-container-query/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -21,17 +21,20 @@
"license": "MIT",
"author": "Isaac J. Lee",
"exports": {
".": "./dist/index.js",
".": {
"types": "./declarations/index.d.ts",
"default": "./dist/index.js"
},
"./*": {
"types": "./dist/*.d.ts",
"types": "./declarations/*.d.ts",
"default": "./dist/*.js"
},
"./addon-main.js": "./addon-main.cjs"
},
"typesVersions": {
"*": {
"*": [
"dist/*"
"declarations/*"
]
}
},
Expand All @@ -41,10 +44,13 @@
},
"files": [
"addon-main.cjs",
"declarations",
"dist"
],
"scripts": {
"build": "rollup --config",
"build": "concurrently \"npm:build:*\" --names \"build:\"",
"build:js": "rollup --config",
"build:types": "glint --declaration",
"lint": "concurrently \"npm:lint:*(!fix)\" --names \"lint:\"",
"lint:fix": "concurrently \"npm:lint:*:fix\" --names \"fix:\"",
"lint:hbs": "ember-template-lint .",
Expand All @@ -53,7 +59,9 @@
"lint:js:fix": "eslint . --fix",
"lint:types": "glint",
"prepack": "rollup --config",
"start": "rollup --config --watch",
"start": "concurrently \"npm:start:*\" --names \"start:\"",
"start:js": "rollup --config --watch --no-watch.clearScreen",
"start:types": "glint --declaration --watch",
"test": "echo 'A v2 addon does not have tests, run tests in test-app'"
},
"dependencies": {
Expand All @@ -75,6 +83,8 @@
"@glint/core": "^1.0.2",
"@glint/environment-ember-loose": "^1.0.2",
"@glint/template": "^1.0.2",
"@rollup/plugin-babel": "^6.0.3",
"@rollup/plugin-node-resolve": "^15.1.0",
"@tsconfig/ember": "^2.0.0",
"@types/ember__component": "^4.0.14",
"@types/ember__destroyable": "^4.0.2",
Expand All @@ -97,7 +107,6 @@
"prettier": "^2.8.8",
"rollup": "^3.25.1",
"rollup-plugin-copy": "^3.4.0",
"rollup-plugin-ts": "^3.2.0",
"typescript": "^5.1.3"
},
"engines": {
Expand Down
25 changes: 19 additions & 6 deletions ember-container-query/rollup.config.mjs
Original file line number Diff line number Diff line change
@@ -1,12 +1,16 @@
import { Addon } from '@embroider/addon-dev/rollup';
import { babel } from '@rollup/plugin-babel';
import { nodeResolve } from '@rollup/plugin-node-resolve';
import copy from 'rollup-plugin-copy';
import typescript from 'rollup-plugin-ts';

const addon = new Addon({
srcDir: 'src',
destDir: 'dist',
});

// Add extensions here, such as ts, gjs, etc that you may import
const extensions = ['.js', '.ts'];

export default {
// This provides defaults that work well alongside `publicEntrypoints` below.
// You can augment this if you need to.
Expand Down Expand Up @@ -41,11 +45,20 @@ export default {
// package names.
addon.dependencies(),

// compile TypeScript to latest JavaScript, including Babel transpilation
typescript({
transpiler: 'babel',
browserslist: false,
transpileOnly: false,
// This babel config should *not* apply presets or compile away ES modules.
// It exists only to provide development niceties for you, like automatic
// template colocation.
//
// By default, this will load the actual babel config from the file
// babel.config.json.
babel({
babelHelpers: 'bundled',
extensions,
}),

// Allows rollup to resolve imports of files with the specified extensions
nodeResolve({
extensions,
}),

// Ensure that standalone .hbs files are properly integrated as Javascript.
Expand Down
1 change: 0 additions & 1 deletion ember-container-query/src/components/container-query.hbs
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
{{! @glint-ignore: ember-element-helper needs to provide Glint signature }}
Copy link
Owner Author

@ijlee2 ijlee2 Jul 5, 2023

Choose a reason for hiding this comment

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

Dan on Discord:

it looks like a bug

specifically, if I set noEmitOnError: false, declarations are emitted

I'm guessing it happens to work with --build because that will always emit declarations, regardless of errors (because --build prioritizes having declarations available for your other project references)

ah

it's because of the @glint-ignore here
https://github.com/ijlee2/ember-container-query/blob/4.0.4/ember-container-query/src/components/container-query.hbs#L1

the bug appears to be that TS internally is counting that as an error that triggers noEmitOnError behavior

if I add an entry for element in the registry in unpublished-development-types, everything works

{{#let (element this.tagName) as |Tag|}}
<Tag
class="container-query"
Expand Down
1 change: 1 addition & 0 deletions ember-container-query/tsconfig.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
{
"extends": "@tsconfig/ember/tsconfig.json",
"compilerOptions": {
"declarationDir": "declarations",
"skipLibCheck": true
},
"include": [
Expand Down
15 changes: 15 additions & 0 deletions ember-container-query/unpublished-development-types/index.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,26 @@

import '@glint/environment-ember-loose';

import { ComponentLike, HelperLike } from '@glint/template';

import EmberContainerQueryRegistry from '../src/template-registry';

interface ElementHelperSignature<T extends string> {
Args: {
Positional: [name: T];
};
Return: ComponentLike<{
Blocks: { default: [] };
Element: T extends keyof HTMLElementTagNameMap
? HTMLElementTagNameMap[T]
: Element;
}>;
}
Comment on lines +10 to +20
Copy link
Owner Author

Choose a reason for hiding this comment

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


declare module '@glint/environment-ember-loose/registry' {
export default interface Registry extends EmberContainerQueryRegistry {
// Add any registry entries from other addons here that your addon itself uses (in non-strict mode templates)
// See https://typed-ember.gitbook.io/glint/using-glint/ember/using-addons
element: HelperLike<ElementHelperSignature>;
}
}
5 changes: 0 additions & 5 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -39,10 +39,5 @@
"enhance: documentation": "Documentation",
"user feedback": "User Feedback"
}
},
"pnpm": {
"patchedDependencies": {
"[email protected]": "patches/[email protected]"
}
}
}
42 changes: 0 additions & 42 deletions patches/[email protected]

This file was deleted.

Loading