-
-
Notifications
You must be signed in to change notification settings - Fork 4.2k
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
Remove window.Ember global #19678
Merged
Merged
Remove window.Ember global #19678
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,64 +1,10 @@ | ||
import { context } from '@ember/-internals/environment'; | ||
import { onEmberGlobalAccess } from '@ember/-internals/overrides'; | ||
import { deprecate } from '@ember/debug'; | ||
import { DEBUG } from '@glimmer/env'; | ||
import require from 'require'; | ||
|
||
(function bootstrap() { | ||
let Ember: unknown; | ||
|
||
let get = () => { | ||
if (!Ember) { | ||
// tslint:disable-next-line: no-require-imports | ||
Ember = require('ember').default; | ||
} | ||
|
||
return Ember; | ||
}; | ||
|
||
if (DEBUG) { | ||
let defaultHandler = () => { | ||
return 'Usage of the Ember Global is deprecated. You should import the Ember module or the specific API instead.'; | ||
}; | ||
|
||
let handler = onEmberGlobalAccess || defaultHandler; | ||
let _get = get; | ||
|
||
get = () => { | ||
let message = handler(); | ||
|
||
if (message !== null) { | ||
deprecate(message, false, { | ||
id: 'ember-global', | ||
until: '4.0.0', | ||
url: 'https://deprecations.emberjs.com/v3.x/#toc_ember-global', | ||
for: 'ember-source', | ||
since: { | ||
enabled: '3.27.0', | ||
}, | ||
}); | ||
} | ||
|
||
return _get(); | ||
}; | ||
} | ||
|
||
function defineEmber(key: string) { | ||
Object.defineProperty(context.exports, key, { | ||
enumerable: true, | ||
configurable: true, | ||
get, | ||
}); | ||
} | ||
|
||
// Bootstrap the global | ||
defineEmber('Ember'); | ||
defineEmber('Em'); | ||
|
||
// Bootstrap Node module | ||
// eslint-disable-next-line no-undef | ||
if (typeof module === 'object' && typeof module.require === 'function') { | ||
// tslint:disable-next-line: no-require-imports | ||
module.exports = Ember = require('ember').default; | ||
module.exports = require('ember').default; | ||
} | ||
})(); |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is maybe the most suspicious change in here. As these tests are simply executing scripts in a context, they don't directly use any module system (CommonJS or ES). Adding
require() {}
to the exports fools Ember into thinking this is a CommonJS env (which is effectively what this line was doing anyway) and thus Ember sets.exports
to beEmber
. This hack only works for one this-which-exports-via-CommonJS in a context.I'm not familiar enough with how this code runs in Fastboot to know if this is a meaningful test. cc @rwjblue
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@rwjblue suggested this should land, and that if Fastboot as a follow up we can address it during the beta.