-
Notifications
You must be signed in to change notification settings - Fork 1.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
Pass options to middleware #9205
Conversation
A couple of questions:
|
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.
should the options passed to middlewares be transformed, be a subset? For example only pass {hasBuild: true} if original options contain path?
No, I don't think so. As mentioned in another comment the serverMiddleware
hook already receives the unfettered options
so this seems fine to me.
not sure what test would be appropriate, check addonMiddlewares receives options in tests/unit/tasks/test-test.js?
If possible, I'd setup a test that actually adds an addon that uses testemMiddleware
and assert that it receives the options.
lib/tasks/test.js
Outdated
addons.push(function () { | ||
return addon.testemMiddleware.apply(addon, [].slice.call(arguments).concat([options])); | ||
}); |
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.
I think this will work on all of our supported Node versions:
addons.push(function () { | |
return addon.testemMiddleware.apply(addon, [].slice.call(arguments).concat([options])); | |
}); | |
addons.push(function () { | |
return addon.testemMiddleware(...arguments, options); | |
}); |
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.
👍 have updated as suggested
5972bba
to
880a89a
Compare
@rwjblue have added the suggested test. It configures a dummy test launcher for the test, so full stack is run, apart from the test apps tests. |
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.
Awesome, thank you!!!
Useful if the middleware is expensive and should be optionally started depending on ember-cli options. For example `ember serve` and `ember test` use a `path` flag to specify an existing ember build to use, without rebuilding. `ember-cli-typescript` will add typechecking middleware regardless of ember using an existing build, the typechecking middleware is not required. This can slow down the initial request to express server significantly. Passing the ember options to middleware will allow middleware to optionally enable different features depending on options
880a89a
to
bcd3346
Compare
I've updated the target of this PR and rebased against the |
Useful if the middleware is expensive and should be optionally started
depending on ember-cli options.
For example
ember serve
andember test
use apath
flag to specifyan existing ember build to use, without rebuilding.
ember-cli-typescript
will add typechecking middleware regardless of ember using an existing
build, the typechecking middleware is not required. This can slow
down the initial request to express server significantly. Passing the
ember options to middleware will allow middleware to optionally enable
different features depending on options
See
ember-cli-typescript
making use of this here typed-ember/ember-cli-typescript#1148