Skip to content
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

SPA Angular 11->12 updates #33353

Merged
merged 10 commits into from
Jun 8, 2021
Merged

SPA Angular 11->12 updates #33353

merged 10 commits into from
Jun 8, 2021

Conversation

HaoK
Copy link
Member

@HaoK HaoK commented Jun 7, 2021

Fixes #33076

Note: When individual auth is enabled, ng test run on the ClientApp will fail due to issues with webpack 5 removing polyfills for node.js core modules, specifically util, and then process due to bootstrap.

ng test output errors

BREAKING CHANGE: webpack < 5 used to include polyfills for node.js core modules by default.
This is no longer the case. Verify if you need this module and configure a polyfill for it.

If you want to include a polyfill, you need to:
        - add a fallback 'resolve.fallback: { "util": require.resolve("util/") }'
        - install 'util'
If you don't want to include a polyfill, you can use an empty module like this:
        resolve.fallback: { "util": false }

But other wise, the angular template seems to runs fine with this PR

@HaoK HaoK requested a review from Pilchie as a code owner June 7, 2021 21:42
@ghost ghost added the area-mvc Includes: MVC, Actions and Controllers, Localization, CORS, most templates label Jun 7, 2021
@HaoK HaoK requested review from javiercn and a team June 7, 2021 21:42
@javiercn
Copy link
Member

javiercn commented Jun 8, 2021

It's fine if we do this, I remember we hit a similar thing when we upgraded to webpack 5 on SignalR and other places.

install 'util'
add a fallback 'resolve.fallback: { "util": require.resolve("util/") }'

@HaoK
Copy link
Member Author

HaoK commented Jun 8, 2021

It wasn't clear how best I could do this easily since angular doesn't expose webpack directly, have to do some kind of webpack custom builder?

@javiercn
Copy link
Member

javiercn commented Jun 8, 2021

@HaoK ahh, that's true.

How does this work on a new template?

@HaoK
Copy link
Member Author

HaoK commented Jun 8, 2021

I'm not sure what codepaths in the auth that actually rely on util or process, its the ng test command that runs into this. I was able to login normally just fine, so I'm not sure if there are actual functionality that stops working due to util/process/browser changes.

@javiercn
Copy link
Member

javiercn commented Jun 8, 2021

@HaoK can you point out what files are causing grief to the tests?

@HaoK
Copy link
Member Author

HaoK commented Jun 8, 2021

@javiercn the login/logout files:


BREAKING CHANGE: webpack < 5 used to include polyfills for node.js core modules by default.
This is no longer the case. Verify if you need this module and configure a polyfill for it.

If you want to include a polyfill, you need to:
        - add a fallback 'resolve.fallback: { "util": require.resolve("util/") }'
        - install 'util'
If you don't want to include a polyfill, you can use an empty module like this:
        resolve.fallback: { "util": false }

./src/api-authorization/logout/logout.component.spec.ts:6:0-27 - Error: Module not found: Error: Can't resolve 'util' in 'C:\angular12\ClientApp\src\api-authorization\logout'

BREAKING CHANGE: webpack < 5 used to include polyfills for node.js core modules by default.
This is no longer the case. Verify if you need this module and configure a polyfill for it.

If you want to include a polyfill, you need to:
        - add a fallback 'resolve.fallback: { "util": require.resolve("util/") }'
        - install 'util'
If you don't want to include a polyfill, you can use an empty module like this:
        resolve.fallback: { "util": false }


√ Browser application bundle generation complete.

./src/api-authorization/login/login.component.spec.ts:7:0-27 - Error: Module not found: Error: Can't resolve 'util' in 'C:\angular12\ClientApp\src\api-authorization\login'

BREAKING CHANGE: webpack < 5 used to include polyfills for node.js core modules by default.
This is no longer the case. Verify if you need this module and configure a polyfill for it.

If you want to include a polyfill, you need to:
        - add a fallback 'resolve.fallback: { "util": require.resolve("util/") }'
        - install 'util'
If you don't want to include a polyfill, you can use an empty module like this:
        resolve.fallback: { "util": false }

./src/api-authorization/logout/logout.component.spec.ts:6:0-27 - Error: Module not found: Error: Can't resolve 'util' in 'C:\angular12\ClientApp\src\api-authorization\logout'

BREAKING CHANGE: webpack < 5 used to include polyfills for node.js core modules by default.
This is no longer the case. Verify if you need this module and configure a polyfill for it.

If you want to include a polyfill, you need to:
        - add a fallback 'resolve.fallback: { "util": require.resolve("util/") }'
        - install 'util'
If you don't want to include a polyfill, you can use an empty module like this:
        resolve.fallback: { "util": false }

@HaoK
Copy link
Member Author

HaoK commented Jun 8, 2021

So I can make the errors go away and the tests pass if I just delete the logging/util usage in both of the spec files, maybe that's the easiest fix

@javiercn
Copy link
Member

javiercn commented Jun 8, 2021

So I can make the errors go away and the tests pass if I just delete the logging/util usage in both of the spec files, maybe that's the easiest fix

That sounds like an appropriate fix.

@HaoK
Copy link
Member Author

HaoK commented Jun 8, 2021

Cool things look good now with ng test, I think this PR is ready to go

@HaoK HaoK merged commit b29d6ad into main Jun 8, 2021
@HaoK HaoK deleted the haok/ang12 branch June 8, 2021 18:50
@ghost ghost added this to the 6.0-preview6 milestone Jun 8, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area-mvc Includes: MVC, Actions and Controllers, Localization, CORS, most templates
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[SPA] Upgrade to angular 12
2 participants