Skip to content
This repository has been archived by the owner on Nov 20, 2023. It is now read-only.

Does not work with Typescript #27

Closed
adamduren opened this issue Feb 11, 2018 · 3 comments
Closed

Does not work with Typescript #27

adamduren opened this issue Feb 11, 2018 · 3 comments

Comments

@adamduren
Copy link

When attempting use use with Webpack I get the following:

Error: ./src/app/app.module.ts
Module parse failed: Unexpected character '@' (27:0)
You may need an appropriate loader to handle this file type.
| import { Services } from '../services';
|
| @NgModule({
|   declarations: [MyApp],
|   imports: [
 @ ./src/app/main.ts 16:0-41
 @ multi ./node_modules/@sentry/webpack-plugin/src/sentry-webpack.module.js ./src/app/main.ts
    at new BuildError (/path-to-project/node_modules/@ionic/app-scripts/dist/util/errors.js:16:28)
    at callback (/path-to-project/node_modules/@ionic/app-scripts/dist/webpack.js:121:28)
    at emitRecords.err (/path-to-project/node_modules/webpack/lib/Compiler.js:269:13)
    at Compiler.emitRecords (/path-to-project/node_modules/webpack/lib/Compiler.js:375:38)
    at emitAssets.err (/path-to-project/node_modules/webpack/lib/Compiler.js:262:10)
    at applyPluginsAsyncSeries1.err (/path-to-project/node_modules/webpack/lib/Compiler.js:368:12)
    at next (/path-to-project/node_modules/tapable/lib/Tapable.js:218:11)
    at Compiler.compiler.plugin (/path-to-project/node_modules/webpack/lib/performance/SizeLimitsPlugin.js:99:4)
    at next (/path-to-project/node_modules/tapable/lib/Tapable.js:220:14)
    at versionPromise.then.then.then.then (/path-to-project/node_modules/@sentry/webpack-plugin/src/index.js:92:21)
@adamduren
Copy link
Author

It appears I was able to fix this by modifying the injectRelease function as such to convert from loaders syntax to rules if loaders is used. The old loaders syntax is used in Ionic. This change is probably not comprehensive but seems to get the job done.

  // added code to convert from loaders syntax to rules syntax
  if (typeof changedCompiler.options.module.loaders !== 'undefined') {
    changedCompiler.options.module.loaders.map(loader => {
      changedCompiler.options.module.rules.push({
        test: loader.test,
        use: [{
          loader: loader.loader,
        }],
      });
    });
  }

  delete changedCompiler.options.module.loaders;

@adamduren
Copy link
Author

Upon thinking about it further I believe it would be better to warn the user about the incompatibility vs attempting to rewrite their webpack config. Thoughts?

@kamilogorek
Copy link
Contributor

Fix published as 1.3.3. Please let us know if it solves the issue :)

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

No branches or pull requests

2 participants