When attempting to execute the @nrwl/workspace:run-commands builder from context.scheduleBuilder in the @nxtend/capacitor plugin on Nx 11, I receive the error "Builder is not a builder".
context.scheduleBuilder('@nrwl/workspace:run-commands, ...) should execute the run-commands builder without error.
git clone [email protected]:nxtend-team/nxtend -b nx-11
cd nxtend
nx build capacitor
cd dist/packages/capacitor
yarn link
cd ../../../../
npx create-nx-workpace myOrg
cd my-org
yarn add -D -E @nxtend/capacitor @nxtend/ionic-react
yarn link @nxtend/capacitor
nx g @nxtend/ionic-react:app myApp --style css
nx run my-app:add:ios
This issue may not be prioritized if details are not provided to help us reproduce the issue.
'Builder is not a builder'
> NX Report complete - copy this into the issue template
Node : 14.15.1
OS : darwin x64
yarn : 1.22.10
nx : Not Found
@nrwl/angular : 11.0.16
@nrwl/cli : 11.0.16
@nrwl/cypress : 11.0.16
@nrwl/devkit : 11.0.16
@nrwl/eslint-plugin-nx : 11.0.16
@nrwl/express : Not Found
@nrwl/jest : 11.0.16
@nrwl/linter : 11.0.16
@nrwl/nest : Not Found
@nrwl/next : Not Found
@nrwl/node : 11.0.16
@nrwl/react : 11.0.16
@nrwl/schematics : Not Found
@nrwl/tao : 11.0.16
@nrwl/web : 11.0.16
@nrwl/workspace : 11.0.16
typescript : 4.0.5
From talking with other plugin authors, it appears that if a default export is added to run-commands.ts then this works fine. Perhaps context.scheduleBuilder became more strict about builders with Angular 11.
Using the run-commands builder directly from the workspace.json also seems to work well.
Can confirm this is also happening when trying to run commands with @nrwl/cypress. In the meantime, I'll downgrade to 10.x
after investigating, I ran into this function
node_modules\@angular-devkit\architect\node\node-modules-architect-host.js
async loadBuilder(info) {
console.log(info.import)
const builder = (await Promise.resolve().then(() => require(info.import))).default;
if (builder[internal_1.BuilderSymbol]) {
return builder;
}
throw new Error('Builder is not a builder');
}
and figured that in packages\workspace\src\builders\run-commands\run-commands.impl.ts if i added this code
export default createBuilder(runCommand);
instead of the current export default async functiont. It works fine
I think its because of the symbols that is not built correctly if not built through the createBuilder function.
builder {
handler: [Function: handler] { jobDescription: {} },
[Symbol(@angular-devkit/architect:builder)]: true,
[Symbol(@angular-devkit/architect:version)]: '0.1100.5'
}
The two symbols are missing, making the scheduleBuilder breaks
Thank you for reporting the issue, folks.
Restored the old commands builder in 11.0.19 to unblock folks. I'll apply a proper fix in January.
Most helpful comment
Thank you for reporting the issue, folks.
Restored the old commands builder in 11.0.19 to unblock folks. I'll apply a proper fix in January.