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

Angular 12 compatibilty #581

Closed
femave opened this issue Oct 31, 2021 · 3 comments · Fixed by #707
Closed

Angular 12 compatibilty #581

femave opened this issue Oct 31, 2021 · 3 comments · Fixed by #707
Assignees
Labels
kind/bug A bug in existing code (including security flaws) P2 Medium: Good to have, but can wait until someone steps up

Comments

@femave
Copy link

femave commented Oct 31, 2021

Hello, as I don't see nobody reporting this and any thing related to angular 2+ I dont know if its only my problem or there is really a bug, but this error appear when I try to run in angular 12, and looks like some kind of babel bug compilation with async functions so I don't know if it can be compatible with angular 12

node 16.1.0
npm 8.1.1

image

@femave femave added kind/bug A bug in existing code (including security flaws) need/triage Needs initial labeling and prioritization labels Oct 31, 2021
@atopal atopal added P2 Medium: Good to have, but can wait until someone steps up and removed need/triage Needs initial labeling and prioritization labels Nov 8, 2021
@funkytek funkytek assigned funkytek and unassigned Codigo-Fuentes Nov 9, 2021
@dchoi27
Copy link
Contributor

dchoi27 commented Nov 10, 2021

Not sure if related: nftstorage/nft.storage#720

@JeffLowe JeffLowe assigned dashcraft and unassigned funkytek Nov 26, 2021
@jkondratowicz
Copy link

Similar error trying to use it in a React app built with Create React App.

Node version v16.5.0
NPM version 7.19.1
React version 17.0.2
react-scripts 4.0.3

Failed to compile.

./node_modules/web3.storage/src/lib.js 356:79
Module parse failed: Unexpected token (356:79)
File was processed with these loaders:
 * ./node_modules/babel-loader/lib/index.js
You may need an additional loader to handle the result of these loaders.
|         /* c8 ignore next 2 */
|         const errorMessage = await res.json();
>         throw new Error(`${res.status} ${res.statusText} ${'- ' + errorMessage?.message || ''}`);
|       }
|

@dashcraft
Copy link
Contributor

For angular 13 (using latest ng new):
I was able to resolve the build issue with the following steps:

  • set "allowSyntheticDefaultImports": true in your tsconfig.json
  • verify your package.json file has the following versions...
{
  "dependencies": {
    "@angular/animations": "~13.0.0",
    "@angular/common": "~13.0.0",
    "@angular/compiler": "~13.0.0",
    "@angular/core": "~13.0.0",
    "@angular/forms": "~13.0.0",
    "@angular/platform-browser": "~13.0.0",
    "@angular/platform-browser-dynamic": "~13.0.0",
    "@angular/router": "~13.0.0",
    "rxjs": "~7.4.0",
    "tslib": "^2.3.0",
    "web3.storage": "^3.4.0",
    "zone.js": "~0.11.4"
  },
  "devDependencies": {
    "@angular-devkit/build-angular": "~13.0.3",
    "@angular/cli": "~13.0.3",
    "@angular/compiler-cli": "~13.0.0",
    "@types/jasmine": "~3.10.0",
    "@types/node": "^12.11.1",
    "jasmine-core": "~3.10.0",
    "karma": "~6.3.0",
    "karma-chrome-launcher": "~3.1.0",
    "karma-coverage": "~2.0.3",
    "karma-jasmine": "~4.0.0",
    "karma-jasmine-html-reporter": "~1.7.0",
    "typescript": "~4.4.3"
  }
}

Make sure that your internal webpack version is:
webpack "5.64.1"

This should be standard with angular 13, but in case it's not, I figured i'd make sure to comment:
@femave can you see if this helps unblock you?

I have a fix that will be inbound for the other issue (angular 12+ and react) here shortly. I need to do some more testing, it breaks using webpack 4 specifically.

alanshaw pushed a commit that referenced this issue Nov 29, 2021
Fixes #581
This pr reworks the problematic error message to not use the coalesce operator to resolve webpack4 issues.
In the future might look at the current rollup config and transpile to es5 or another valid syntax and export for older build setups. This however is a quick and easy solution for this specific build issue.

I verified this by creating a webpack 4 config and found the issue and resolved locally. This isn't the most foolproof way, but whenever I fixed it this way, create-react-app using webpack 4 successfully compiled, and angular 13 does not have this issue, it used webpack 5 now.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
kind/bug A bug in existing code (including security flaws) P2 Medium: Good to have, but can wait until someone steps up
Projects
None yet
Development

Successfully merging a pull request may close this issue.

7 participants