Skip to content
Merged
Show file tree
Hide file tree
Changes from 2 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
22 changes: 19 additions & 3 deletions addon/addon/index.js
Original file line number Diff line number Diff line change
@@ -1,11 +1,25 @@
/* globals requirejs, require */

import Ember from 'ember';
import { assert, deprecate, warn } from '@ember/debug';
import EmberObject from '@ember/object';
import { dasherize, classify, underscore } from './string';
import { DEBUG } from '@glimmer/env';
import classFactory from './utils/class-factory';
import {
macroCondition,
dependencySatisfies,
importSync,
} from '@embroider/macros';

let getOwner;

if (macroCondition(dependencySatisfies('ember-source', '>= 4.11'))) {
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Since this PR is now breaking anyway (which I agree with), how about not doing these macroCondition shenanigans and just supporting ember >= 4.11?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

done! I like this plan

getOwner = importSync('@ember/owner').getOwner;
} else {
getOwner = importSync('@ember/application').getOwner;
}

import { TEMPLATES } from './template-cache';

if (typeof requirejs.entries === 'undefined') {
requirejs.entries = requirejs._eak_seen;
Expand Down Expand Up @@ -295,7 +309,7 @@ class Resolver extends EmberObject {
resolveTemplate(parsedName) {
let resolved = this.resolveOther(parsedName);
if (resolved == null) {
resolved = Ember.TEMPLATES[parsedName.fullNameWithoutType];
resolved = TEMPLATES[parsedName.fullNameWithoutType];
}
return resolved;
}
Expand Down Expand Up @@ -459,7 +473,9 @@ class Resolver extends EmberObject {

// only needed until 1.6.0-beta.2 can be required
_logLookup(found, parsedName, description) {
if (!Ember.ENV.LOG_MODULE_RESOLVER && !parsedName.root.LOG_RESOLVER) {
let owner = getOwner(this);
let env = owner?.resolveRegistration?.('config:environment');
if (!env?.LOG_MODULE_RESOLVER && !parsedName.root.LOG_RESOLVER) {
return;
}

Expand Down
8 changes: 8 additions & 0 deletions addon/addon/template-cache.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
/**
* Originally: https://github.com/emberjs/ember.js/blob/28444d536fa20debef2a67e2f18c5eb11113a4b5/packages/%40ember/-internals/glimmer/lib/template_registry.ts#L9
*
* import { TEMPLATES } from 'ember';
*
* Removed for RFC 1003
*/
export let TEMPLATES = {};
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Is this a breaking change? If people could previously add to Ember.TEMPLATES?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

it's a private undocumented API, so if their code breaks, that's on them

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

another example: emberjs/ember.js#20632 (comment)

🙈

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

It was definitely public once which is probably why I remember it.

I think it would be reasonable to make this a breaking change for ember-resolver, just so anybody that updates it before ember-source (& the deprecation) knows to look a bit closer. Doesn't really cost anything.

Copy link
Copy Markdown
Contributor Author

@NullVoxPopuli NullVoxPopuli Jun 6, 2024

Choose a reason for hiding this comment

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

It was definitely public once

uuggghh gross :(
(glad that era is over! haha)

I think it would be reasonable to make this a breaking change for ember-resolver,

fair enough! 🎉

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

There's no point in keeping this. Just drop it.

Ember.TEMPLATES is the thing that gets auto-populated from your HTML like:

<script type="text/x-handlebars" data-template-name="my-component">hello world</script>

A new major of ember-resolver could document that it no longer supports that pattern.

If people are manually stuffing templates into Ember.TEMPLATES, we don't want them to refactor that code to stuff the templates into this template-cache instead. Tell them to use register.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

done

2 changes: 1 addition & 1 deletion addon/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -23,9 +23,9 @@
},
"scripts": {},
"dependencies": {
"@embroider/macros": "^1.16.2",
"ember-cli-babel": "^7.26.11"
},
"devDependencies": {},
"peerDependencies": {
"ember-source": "^4.8.3 || >= 5.0.0"
},
Expand Down
Loading