-
-
Notifications
You must be signed in to change notification settings - Fork 9.4k
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
WIP: feat(angular): add ivy support with JIT #11157
Changes from all commits
d79bf0f
2a24243
bfa463c
0d208c0
0e951ff
2650e8a
9685c87
1406119
5a2fd92
e13e348
120c5c4
70d95d7
942da16
28b6e51
d6a36bd
4720e93
1ead32b
2bc3ef4
0a36612
1be1120
e506b81
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,7 @@ | ||
module.exports = { | ||
preset: 'jest-preset-angular', | ||
setupFilesAfterEnv: ['<rootDir>/setup-jest.ts'], | ||
moduleNameMapper: { | ||
'@storybook/node-logger': '<rootDir>/../../lib/node-logger/dist/cjs/index.js', | ||
}, | ||
}; |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,6 @@ | ||
import { buildStatic } from '@storybook/core/server'; | ||
import { runNgcc } from './ngcc-execution'; | ||
import options from './options'; | ||
|
||
runNgcc(); | ||
buildStatic(options); |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,6 @@ | ||
import { buildDev } from '@storybook/core/server'; | ||
import { runNgcc } from './ngcc-execution'; | ||
import options from './options'; | ||
|
||
runNgcc(); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This is a synchronous operation, correct? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. You can choose https://github.com/angular/angular/blob/master/packages/compiler-cli/ngcc/index.ts#L17 If I would provide There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. You should be aware that, in sync mode, ngcc will crash out if there is another ngcc process running at the same time - it is not able to wait like it can in async mode. This is probably not a problem but worth being aware of. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Thanks for the info! I can imagine that someone starts the app + storybook in parallel right after installing all dependencies If it is that simple to prevent a crash then let's do this 🙂 There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. If you can call There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. That error indicates that you are somehow triggering ngcc via its command line executable. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. No, only from the code. I extracted the code from this PR in a smaller external package which makes it easier to see what happens: https://github.com/storybookjs/addon-angular-ivy/blob/main/src/preset/index.ts That's all There are 2 ways to avoid the error
No other prebuild steps involved: https://github.com/storybookjs/addon-angular-ivy/blob/main/package.json#L22 There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Oh I just realised... in async mode we kick off child processes, which will receive the arguments passed to the original parent process. Perhaps this is how they are getting passed to ngcc. I'll investigate There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Perhaps this is where it is coming from? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. A workaround would be to clear the command line args before triggering ngcc: process.argv.length = 0; |
||
buildDev(options); |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
import path from 'path'; | ||
import { process as ngccProcess } from '@angular/compiler-cli/ngcc'; | ||
|
||
/** | ||
* Run ngcc for converting modules to ivy format before starting storybook | ||
* This step is needed in order to support Ivy in storybook | ||
* | ||
* Information about Ivy can be found here https://angular.io/guide/ivy | ||
*/ | ||
export function runNgcc() { | ||
ngccProcess({ | ||
basePath: path.join(process.cwd(), 'node_modules'), // absolute path to node_modules | ||
createNewEntryPointFormats: true, // --create-ivy-entry-points | ||
compileAllFormats: false, // --first-only | ||
}); | ||
} |
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 honestly don't know how jest managed to successfully run tests with external packages without
moduleNameMapper
before 🤔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.
Now
build-storybook
fails withI guess that's not the solution we were looking for