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

Migrate from requirejs.entries to has. #849

Merged
merged 2 commits into from
May 6, 2020
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
Original file line number Diff line number Diff line change
@@ -1,11 +1,9 @@
/* globals global, requirejs */

import Resolver from '@ember/application/resolver';
import ApplicationInstance from '@ember/application/instance';
import Application from '@ember/application';
import EmberObject from '@ember/object';

import require from 'require';
import require, { has } from 'require';
import Ember from 'ember';

/**
Expand Down Expand Up @@ -91,7 +89,7 @@ export default function (resolver: Resolver) {

exposeRegistryMethodsWithoutDeprecations(container);

if ((requirejs as any).entries['ember-data/setup-container']) {
if (has('ember-data/setup-container')) {
// ember-data is a proper ember-cli addon since 2.3; if no 'import
// 'ember-data'' is present somewhere in the tests, there is also no `DS`
// available on the globalContext and hence ember-data wouldn't be setup
Expand Down
2 changes: 1 addition & 1 deletion tsconfig.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"compilerOptions": {
"target": "es2017",
"allowJs": true,
"allowJs": false,
"moduleResolution": "node",
"allowSyntheticDefaultImports": true,
"noImplicitAny": true,
Expand Down
1 change: 1 addition & 0 deletions types/require.d.ts
Original file line number Diff line number Diff line change
@@ -1 +1,2 @@
export default function <T = any>(moduleName: string): T;
export function has<T = any>(moduleName: string): T;
Copy link
Contributor

Choose a reason for hiding this comment

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

Seems this should return boolean

Copy link
Member Author

Choose a reason for hiding this comment

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

Doh! you are correct

Copy link
Member Author

Choose a reason for hiding this comment

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