8000 [CLEANUP] Clean up old `broccoli-builder` fallback by bertdeblock · Pull Request #10593 · ember-cli/ember-cli · GitHub
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content

[CLEANUP] Clean up old broccoli-builder fallback #10593

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

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations 8000
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions docs/error-propagation.md
8000
Original file line number Diff line number Diff line change
Expand Up @@ -26,17 +26,17 @@ Error contains information of where in the file error occurred and what kind of
Because `ember-cli-htmlbars` is based on `broccoli-persistent-filter`, technically `broccoli-persistent-filter`
will catch the exception first. For example, we attach `file` and `treeDir` information to errors [here](https://github.com/stefanpenner/broccoli-persistent-filter/blob/v1.3.1/index.js#L267-L272).

+ `broccoli-builder` catches the error
+ `broccoli` catches the error

Ember CLI uses `broccoli-builder` to build its trees so if `broccoli-builder` throws an error,
Ember CLI uses `broccoli` to build its trees so if `broccoli` throws an error,
Ember CLI is aware and can act accordingly.

At this level, we can attach more information to the error, like `broccoli` node/annotation.

+ `broccoli-middleware` catches the error

This is where we return an error page for the browser. Given all the information, we get from `ember-cli-htmlbars`
and `broccoli-builder`, we show an error page.
and `broccoli`, we show an error page.

## Error object

Expand Down
64 changes: 13 additions & 51 deletions lib/models/builder.js
Original file line number Diff line number Diff line change
Expand Up @@ -24,9 +24,6 @@ class Builder extends CoreObject {
constructor(options) {
super(options);

// Use Broccoli 2.0 by default, if this fails due to .read/.rebuild API, fallback to broccoli-builder
this.broccoliBuilderFallback = false;

this._instantiationStack = new Error().stack.replace(/[^\n]*\n/, '');
this._cleanup = this.cleanup.bind(this);

Expand Down Expand Up @@ -67,31 +64,8 @@ class Builder extends CoreObject {

this.tree = await this.readBuildFile(this.project.root);

let broccoli = require('broccoli');

try {
this.builder = new broccoli.Builder(this.tree);
return;
} catch (e) {
// Catch here to trap InvalidNodeError. If this is thrown, it's because the node provided is not valid
// and likely uses the old .read/.rebuild API, so fallback to broccoli-builder that supports that API
if (
!(e instanceof broccoli.Builder.InvalidNodeError) ||
e.message.indexOf('The .read/.rebuild API is no longer supported as of Broccoli 1.0') === -1
) {
throw e;
}
const broccoli = require('broccoli');

// Fallback to broccoli-builder
let error = `Invalid Broccoli2 node detected, falling back to broccoli-builder. Broccoli error:\n`;
error += `---------------\n`;
error += e.message;
error += `---------------\n`;
this.ui.writeWarnLine(error);
}

broccoli = require('broccoli-builder');
this.broccoliBuilderFallback = true;
this.builder = new broccoli.Builder(this.tree);
}

Expand Down Expand Up @@ -179,7 +153,7 @@ class Builder extends CoreObject {
try {
this.project._instrumentation.start('build');

if (addWatchDirCallback && !this.broccoliBuilderFallback) {
if (addWatchDirCallback) {
for (let path of this.builder.watchedPaths) {
addWatchDirCallback(path);
}
Expand All @@ -193,24 +167,16 @@ class Builder extends CoreObject {

await this.processAddonBuildSteps('preBuild');

if (this.broccoliBuilderFallback) {
try {
buildResults = await this.builder.build(addWatchDirCallback);
} catch (error) {
this.throwFormattedBroccoliError(error);
}
} else {
try {
await this.builder.build();

// build legacy style results object (this is passed to various addon APIs)
buildResults = {
directory: this.builder.outputPath,
graph: this.builder.outputNodeWrapper,
};
} catch (error) {
this.throwFormattedBroccoliError(error);
}
try {
await this.builder.build();

// build legacy style results object (this is passed to various addon APIs)
buildResults = {
directory: this.builder.outputPath,
graph: this.builder.outputNodeWrapper,
};
} catch (error) {
this.throwFormattedBroccoliError(error);
}

await this.processAddonBuildSteps('postBuild', buildResults);
Expand Down Expand Up @@ -316,12 +282,8 @@ class Builder extends CoreObject {
};
}
if (!broccoliPayload.versions) {
let builderVersion = this.broccoliBuilderFallback
? require('broccoli-builder/package').version
: require('broccoli/package').version;

broccoliPayload.versions = {
'broccoli-builder': builderVersion,
broccoli: require('broccoli/package').version,
node: process.version,
};
}
Expand Down
1 change: 0 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,6 @@
"@pnpm/find-workspace-dir": "^7.0.2",
"babel-remove-types": "^1.0.0",
"broccoli": "^3.5.2",
"broccoli-builder": "^0.18.14",
"broccoli-concat": "^4.2.5",
"broccoli-config-loader": "^1.0.1",
"broccoli-config-replace": "^1.1.2",
Expand Down
74 changes: 33 additions & 41 deletions pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading
Loading
0