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

Error: Module parse failed: 'import' and 'export' may appear only with 'sourceType: module' #8674

Closed
Nannny opened this issue Feb 20, 2022 · 9 comments · Fixed by #8688
Closed

Comments

@Nannny
Copy link

Nannny commented Feb 20, 2022

typeorm: 0.2.43
ionic: 6.0.8
angular:12

./node_modules/typeorm/browser/index.js:3:0 - Error: Module parse failed: 'import' and 'export' may appear only with 'sourceType: module' (3:0)
File was processed with these loaders:

  • ./node_modules/@angular-devkit/build-angular/src/babel/webpack-loader.js
  • ./node_modules/@ngtools/webpack/src/ivy/index.js
  • ./node_modules/source-map-loader/dist/cjs.js
    You may need an additional loader to handle the result of these loaders.
    | /*!
    | */

import "reflect-metadata";

@chriswep
Copy link
Contributor

I'm seeing the same issue. It looks like browser builds are broken since #8536

@pleerock
Copy link
Member

adding @giladgd

@giladgd
Copy link
Contributor

giladgd commented Feb 21, 2022

@Nannny Can you please provide an example project I could use to reproduce the issue?

@Nannny
Copy link
Author

Nannny commented Feb 22, 2022

@Nannny Can you please provide an example project I could use to reproduce the issue?

hi @giladgd , i was downgraded @ionic/angular to 5.0.0, angular to 11.2.14 ,caused aonther errors:

Error: ./node_modules/typeorm/index.mjs 181:4-11
"export 'default' (imported as 'TypeORM') was not found in './index.js'

Error: ./node_modules/typeorm/index.mjs 362:15-22
"export 'default' (imported as 'TypeORM') was not found in './index.js'

This is a part of my package.json:

dependencies:
"@angular/common": "~11.2.14",
"@angular/core": "~11.2.14",
"@angular/forms": "~11.2.14",
"@angular/platform-browser": "~11.2.14",
"@angular/platform-browser-dynamic": "~11.2.14",
"@angular/router": "~11.2.14",
"@ionic-native/app-update": "^5.24.0",
"@ionic-native/background-mode": "^5.24.0",
"@ionic-native/ble": "^5.24.0",
"@ionic-native/bluetooth-serial": "^5.24.0",
"@ionic-native/camera": "^5.24.0",
"@ionic-native/core": "^5.0.7",
"@ionic-native/file": "^5.24.0",
"@ionic-native/file-path": "^5.24.0",
"@ionic-native/geolocation": "^5.29.0",
"@ionic-native/image-picker": "^5.28.0",
"@ionic-native/native-storage": "^5.24.0",
"@ionic-native/splash-screen": "^5.0.0",
"@ionic-native/sqlite": "^5.24.0",
"@ionic-native/status-bar": "^5.0.0",
"@ionic/angular": "^5.0.0",

devDependencies:
"@angular-builders/custom-webpack": "^10.0.1",
"@angular-devkit/build-angular": "~0.1102.18",
"@angular/cli": "~11.2.18",
"@angular/compiler": "~11.2.14",
"@angular/compiler-cli": "~11.2.14",
"@angular/language-service": "~11.2.14",
"@ionic/angular-toolkit": "^2.1.1",
"@ionic/app-scripts": "^3.2.4",
"@types/axios": "^0.14.0",
"@types/jasmine": "~3.6.0",
"@types/jasminewd2": "~2.0.3",
"@types/node": "^12.11.1",

@chriswep
Copy link
Contributor

@giladgd i created a repository for you: https://github.com/chriswep/typeorm-esm-browser

just run yarn and ng build and you see the error. it is just a basic angular 13 setup with typeorm.

giladgd added a commit to giladgd/typeorm that referenced this issue Feb 22, 2022
giladgd added a commit to giladgd/typeorm that referenced this issue Feb 22, 2022
@giladgd
Copy link
Contributor

giladgd commented Feb 22, 2022

Thanks @chriswep For the repo :)
@pleerock I've opened #8688 to fix this issue

pleerock pushed a commit that referenced this issue Feb 22, 2022
@pleerock
Copy link
Member

thanks @giladgd a lot for the quick help

@riban-bgi
Copy link

./node_modules/@angular-architects/module-federation/src/index.js:1:0 - Error: Module parse failed: 'import' and 'export' may appear only with 'sourceType: module' (1:0)
File was processed with these loaders:

  • ./node_modules/@angular-devkit/build-angular/src/tools/babel/webpack-loader.js
  • ./node_modules/source-map-loader/dist/cjs.js
    You may need an additional loader to handle the result of these loaders.

export * from '@angular-architects/module-federation-runtime';

Need help when i build then its gave error

@phoenixxd
Copy link

./node_modules/@angular-architects/module-federation/src/index.js:1:0 - Error: Module parse failed: 'import' and 'export' may appear only with 'sourceType: module' (1:0) File was processed with these loaders:

  • ./node_modules/@angular-devkit/build-angular/src/tools/babel/webpack-loader.js
  • ./node_modules/source-map-loader/dist/cjs.js
    You may need an additional loader to handle the result of these loaders.

export * from '@angular-architects/module-federation-runtime';

Need help when i build then its gave error

I'm facing the same error. Whenever I'm trying to use re-exports it crashes and prints the error you specified.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

6 participants