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

Change htmlSafe and isHTMLSafe import path #38

Merged
merged 2 commits into from
Dec 14, 2017

Conversation

Serabe
Copy link
Contributor

@Serabe Serabe commented Oct 12, 2017

Deprecates importing it from @ember/string and adds the replacement
to @ember/template.

mappings.json Outdated
"deprecated": false
"deprecated": true,
"replacement": {
"module": "@ember/component",
Copy link
Member

Choose a reason for hiding this comment

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

@ember/template 😉

@Serabe Serabe force-pushed the fix/mv-ishtml-to-component branch from 3dff4aa to 5078d8f Compare October 12, 2017 09:16
@locks
Copy link
Contributor

locks commented Oct 12, 2017

@Turbo87 re-👀

Copy link
Member

@Turbo87 Turbo87 left a comment

Choose a reason for hiding this comment

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

would like @rwjblue to verify though

@rwjblue
Copy link
Member

rwjblue commented Oct 12, 2017

See #37 (comment), we need the ability to have the same import map to different globals based on Ember version. Specifically, rolling this change out (mapping import { isHTMLSafe } from '@ember/template' to Ember.String.isHTMLSafe as is done in this PR) will trigger a deprecation for specific versions of Ember (once the Ember.String RFC is landed in an Ember version).

We need to have two entries for import { isHTMLSafe } from '@ember/template':

  • one entry for Ember < 2.18 that maps (as this PR does) to Ember.String.isHTMLSafe
  • one entry for Ember >= 2.18 (assuming the Ember.String deprecations land there) that maps to some other global location

@Serabe
Copy link
Contributor Author

Serabe commented Oct 12, 2017

Will there be a way to provide the current version of Ember to all the projects using this data (specially eslint plugin, and babel plugin)?

@Turbo87
Copy link
Member

Turbo87 commented Oct 14, 2017

I am quite worried about the complexity that will be introduced by this proposal. Especially since it's just working around the fact that we're still introducing new globals instead of using proper modules...

@rwjblue
Copy link
Member

rwjblue commented Oct 14, 2017

@Turbo87 - Have I missed something in my statement above? Am I making it more complicated needlessly?

@Turbo87
Copy link
Member

Turbo87 commented Oct 14, 2017

Am I making it more complicated needlessly?

probably not needlessly, I'm just worried about adding more and more responsibilities to this package

@Serabe
Copy link
Contributor Author

Serabe commented Oct 15, 2017

The only other solution I can think of is splitting the data among different packages which I think would be worse, but open to other options.

@rwjblue
Copy link
Member

rwjblue commented Nov 8, 2017

After rethinking here, I think we can actually a simpler thing.

Leave the current changes in the PR alone (deprecate: true with an alternative for import { isHTMLSafe, htmlSafe } from '@ember/string'), then add new entries (which are not deprecated) for import { htmlSafe, isHTMLSafe } from '@ember/template'. Since Ember will have to continue to ship Ember.String.{isHTMLSafe,htmlSafe} throughout its 3.x cycle, we can continue to map both the @ember/string and @ember/template versions back to Ember.String API's without issue.

@Serabe - Can you update this PR with those two new entries?

@Serabe
Copy link
Contributor Author

Serabe commented Nov 8, 2017

I'll do it tonight.

@Turbo87 Turbo87 changed the title Fix htmlSafe and isHTMLSafe data Change htmlSafe and isHTMLSafe import path Nov 8, 2017
Copy link
Member

@Turbo87 Turbo87 left a comment

Choose a reason for hiding this comment

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

shouldn't this PR also add the @ember/template equivalents?

edit: whoops, just noticed that that is what @rwjblue also suggested

Deprecates importing it from `@ember/string` and adds the replacement
to `@ember/template`.
@Serabe Serabe force-pushed the fix/mv-ishtml-to-component branch from 5078d8f to f9fdcc8 Compare December 12, 2017 00:01
@Serabe
Copy link
Contributor Author

Serabe commented Dec 12, 2017

Rebased and updated. :(

mappings.json Outdated
}
},
{
"global": "Ember._Template.htmlSafe",
Copy link
Member

Choose a reason for hiding this comment

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

Hmm, I think this needs to stay Ember.String.htmlsafe until we have a way to ensure that the transpilation will work for both [email protected] and [email protected] (soon to include this global).

Thoughts?

Copy link
Member

@Turbo87 Turbo87 Dec 13, 2017

Choose a reason for hiding this comment

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

something like global: ["Ember._Template.htmlSafe", "Ember.String.htmlSafe"]?

but if we're going to make the format more complicated we should definitely document the format better 🤔

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 would change it and think how to do different transpilations depending on the version. Keeping an array would force us to transpile to something like:

var x = (Ember._Template && Ember._Template.htmlSafe) || (Ember.String && Ember.String.htmlSafe);

I rather keep two versions (0.x for Ember.String and 0.(x+y) for Ember._Template) than start doing that. In case we want to keep all in one version, I would rather see something like:

{
  "global": [{ "version_selector": "<2.18.0", "global": "Ember.String.htmlSafe"}, { "version_selector": ">=2.18.0", "global": "Ember._Template.htmlSafe"}]
}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants