-
Notifications
You must be signed in to change notification settings - Fork 69
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
Allow to require module path from whitelisted dependency #200
Merged
Merged
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
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 |
---|---|---|
@@ -0,0 +1,12 @@ | ||
'use strict'; | ||
|
||
function getPackageName(modulePath) { | ||
let parts = modulePath.split('/'); | ||
|
||
if (modulePath[0] === '@') { | ||
return parts[0] + '/' + parts[1]; | ||
} | ||
return parts[0]; | ||
} | ||
|
||
module.exports = getPackageName; |
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 |
---|---|---|
@@ -0,0 +1,23 @@ | ||
'use strict'; | ||
|
||
const expect = require('chai').expect; | ||
const fs = require('fs'); | ||
const path = require('path'); | ||
const fixture = require('./helpers/fixture-path'); | ||
const FastBoot = require('./../src/index'); | ||
|
||
describe.only("FastBoot with dependencies", function() { | ||
it("it works with dependencies", function() { | ||
var fastboot = new FastBoot({ | ||
distPath: fixture('app-with-dependencies') | ||
}); | ||
|
||
return fastboot.visit('/') | ||
.then(r => r.html()) | ||
.then(html => { | ||
expect(html).to.match(/https:\/\/emberjs.com/); | ||
expect(html).to.match(/FOO/); | ||
expect(html).to.match(/BAR/); | ||
}); | ||
}); | ||
}); |
63 changes: 63 additions & 0 deletions
63
test/fixtures/app-with-dependencies/assets/app-with-dependencies-fastboot.js
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 |
---|---|---|
@@ -0,0 +1,63 @@ | ||
define('app-with-dependencies/initializers/ajax', ['exports'], function (exports) { | ||
'use strict'; | ||
|
||
Object.defineProperty(exports, "__esModule", { | ||
value: true | ||
}); | ||
|
||
|
||
const { get } = Ember; /* globals najax */ | ||
|
||
|
||
var nodeAjax = function (options) { | ||
let httpRegex = /^https?:\/\//; | ||
let protocolRelativeRegex = /^\/\//; | ||
let protocol = get(this, 'fastboot.request.protocol'); | ||
|
||
if (protocolRelativeRegex.test(options.url)) { | ||
options.url = protocol + options.url; | ||
} else if (!httpRegex.test(options.url)) { | ||
try { | ||
options.url = protocol + '//' + get(this, 'fastboot.request.host') + options.url; | ||
} catch (fbError) { | ||
throw new Error('You are using Ember Data with no host defined in your adapter. This will attempt to use the host of the FastBoot request, which is not configured for the current host of this request. Please set the hostWhitelist property for in your environment.js. FastBoot Error: ' + fbError.message); | ||
} | ||
} | ||
|
||
if (najax) { | ||
najax(options); | ||
} else { | ||
throw new Error('najax does not seem to be defined in your app. Did you override it via `addOrOverrideSandboxGlobals` in the fastboot server?'); | ||
} | ||
}; | ||
|
||
exports.default = { | ||
name: 'ajax-service', | ||
|
||
initialize: function (application) { | ||
application.register('ajax:node', nodeAjax, { instantiate: false }); | ||
application.inject('adapter', '_ajaxRequest', 'ajax:node'); | ||
application.inject('adapter', 'fastboot', 'service:fastboot'); | ||
} | ||
}; | ||
}); | ||
define('app-with-dependencies/initializers/error-handler', ['exports'], function (exports) { | ||
'use strict'; | ||
|
||
Object.defineProperty(exports, "__esModule", { | ||
value: true | ||
}); | ||
exports.default = { | ||
name: 'error-handler', | ||
|
||
initialize: function (application) { | ||
if (!Ember.onerror) { | ||
// if no onerror handler is defined, define one for fastboot environments | ||
Ember.onerror = function (err) { | ||
let errorMessage = `There was an error running your app in fastboot. More info about the error: \n ${err.stack || err}`; | ||
Ember.Logger.error(errorMessage); | ||
}; | ||
} | ||
} | ||
}; | ||
});//# sourceMappingURL=app-with-dependencies-fastboot.map |
Oops, something went wrong.
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 branch is not required since
resolve.sync
will take care of it.