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

Bring @glimmer/component into ember repo #20751

Merged
merged 4 commits into from
Oct 29, 2024
Merged
Show file tree
Hide file tree
Changes from 1 commit
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
2 changes: 2 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,8 @@ jobs:
steps:
- uses: actions/checkout@v4
- uses: ./.github/actions/setup
- name: build types
run: pnpm build:types
- name: Check published and internal types
run: pnpm type-check

Expand Down
4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -113,7 +113,7 @@
"@babel/preset-env": "^7.16.11",
"@babel/types": "^7.22.5",
"@embroider/shared-internals": "^2.5.0",
"@glimmer/component": "^1.1.2",
"@glimmer/component": "workspace:^",
"@rollup/plugin-babel": "^6.0.4",
"@simple-dom/document": "^1.4.0",
"@swc-node/register": "^1.6.8",
Expand Down Expand Up @@ -173,7 +173,7 @@
}
},
"peerDependencies": {
"@glimmer/component": "^1.1.2"
"@glimmer/component": "workspace:^"
},
"engines": {
"node": ">= 18.*"
Expand Down
5 changes: 3 additions & 2 deletions packages/@ember/-internals/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
"version": "0.0.0",
"description": "Internal APIs shared by Ember packages. Warning: this package does not follow SemVer and is subject to break at any time!",
"type": "module",
"private": true,
Copy link
Contributor

Choose a reason for hiding this comment

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

I verified that all the other package.jsons were also private.
Surprised this wasn't caught before -- but also not surprised -- because we're not using release-plan (or anything to enforce package.json consistency)

Copy link
Contributor

Choose a reason for hiding this comment

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

I think for now, we could very well set up release plan for just @glimmer/component if we wanted.

"exports": {
"./browser-environment": "./browser-environment/index.ts",
"./container": "./container/index.ts",
Expand All @@ -23,7 +24,7 @@
"@ember/application": "workspace:*",
"@ember/array": "workspace:*",
"@ember/canary-features": "workspace:*",
"@ember/component": "workspace:*",
"@ember/component": "workspace:^",
"@ember/controller": "workspace:*",
"@ember/debug": "workspace:*",
"@ember/destroyable": "workspace:*",
Expand All @@ -40,7 +41,7 @@
"@ember/template-factory": "workspace:*",
"@ember/utils": "workspace:*",
"@glimmer/compiler": "0.92.0",
"@glimmer/component": "^1.1.2",
"@glimmer/component": "workspace:^",
"@glimmer/destroyable": "0.92.0",
"@glimmer/env": "^0.1.7",
"@glimmer/global-context": "0.92.0",
Expand Down
4 changes: 2 additions & 2 deletions packages/@ember/owner/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,8 @@
"@ember/object": "workspace:*",
"@ember/routing": "workspace:*",
"@ember/runloop": "workspace:*",
"@glimmer/component": "^1.1.2",
"@glimmer/component": "workspace:^",
"@glimmer/env": "^0.1.7",
"expect-type": "^0.15.0"
}
}
}
5 changes: 5 additions & 0 deletions packages/@glimmer/component/addon-main.cjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
/* eslint-env node */
'use strict';

const { addonV1Shim } = require('@embroider/addon-shim');
module.exports = addonV1Shim(__dirname);
41 changes: 41 additions & 0 deletions packages/@glimmer/component/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
{
"name": "@glimmer/component",
"version": "2.0.0",
"description": "Glimmer component library",
"exports": {
".": "./dist/index.js"
},
"keywords": [
"ember-addon"
],
"license": "MIT",
"contributors": [
"Dan Gebhardt <[email protected]>",
"Robert Jackson <[email protected]>",
"Tom Dale <[email protected]>"
],
"repository": "https://github.com/emberjs/ember.js",
"scripts": {},
"dependencies": {
"@embroider/addon-shim": "^1.8.9",
"@glimmer/env": "^0.1.7"
},
"devDependencies": {
"typescript": "5.1"
},
"engines": {
"node": ">= 18"
},
"typesVersions": {
"*": {
"*": [
"dist/*"
]
}
},
"ember-addon": {
Copy link
Contributor

Choose a reason for hiding this comment

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

since glimmer/component doesn't depend on any embery things, does it need to be an addon at all?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I thought that too, but it imports from @ember/destroyable, @ember/component, and @ember/runloop. Those only work in an addon.

"type": "addon",
"version": 2,
"main": "addon-main.cjs"
}
}
34 changes: 34 additions & 0 deletions packages/@glimmer/component/src/-private/base-component-manager.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
import { DEBUG } from '@glimmer/env';
import type { Arguments, ComponentManager, ComponentCapabilities } from '@glimmer/interfaces';
import { type default as BaseComponent, ARGS_SET } from './component';

export interface Constructor<T> {
new (owner: unknown, args: Record<string, unknown>): T;
}

export default abstract class BaseComponentManager<GlimmerComponent extends BaseComponent>
implements ComponentManager<GlimmerComponent>
{
abstract capabilities: ComponentCapabilities;

private owner: unknown;

constructor(owner: unknown) {
this.owner = owner;
}

createComponent(
ComponentClass: Constructor<GlimmerComponent>,
args: Arguments
): GlimmerComponent {
if (DEBUG) {
ARGS_SET.set(args.named, true);
}

return new ComponentClass(this.owner, args.named);
}

getContext(component: GlimmerComponent): GlimmerComponent {
return component;
}
}
Loading