webpack.config.js - Cannot read property 'emit' of undefined

未关闭
#80 4 条评论 0 个 reaction 已指派 0 人 在 GitHub 查看

还没有人认领这个 Issue。

评估

难度
3/5
预计耗时
1-2 天
新手友好度
28/100
Issue 类型
缺陷
描述清晰度
需要澄清
活跃度
停滞
技术栈
javascript, webpack
领域
build-system

调研方向

首先,使用 ionic cordova build android,通过所示的 config/webpack.config.js 配置复现该失败。阅读第 22 行的 node_modules/webpack-obfuscator/dist/index.js 以及周围的 Webpack 堆栈,包括 ionic-app-scripts 3.2.4。完成的标准是确定不兼容或缺失的集成细节,并让构建越过 emit 错误。

由索引模型根据 Issue 内容生成。

描述

Hi - I'm not sure if this is the right place to post this but I could use some help.

I'm developing a project using Cordova/Ionic 3, and I'm trying to add the javascript-obfuscator plugin following this guide.

I've installed the javascript-obfuscator package via NPM, I've got a config folder with a copy of webpack.config.js that's being recognised by my project and used. I've added my plugin:

var JavaScriptObfuscator = require('webpack-obfuscator');

And in the plugins section:

  plugins: [
    new Dotenv({
      path: '.env.dev', // load this now instead of the ones in '.env'
      systemvars: true, // load all the predefined 'process.env' variables which will trump anything local per dotenv specs.
      silent: true // hide any errors
    }),
    ionicWebpackFactory.getIonicEnvironmentPlugin(),
    ionicWebpackFactory.getCommonChunksPlugin(),
    new JavaScriptObfuscator({
      stringArrayEncoding: 'base64'
    })
  ],

But when I run the ionic cordova run android command, I get the following output:

PS C:\MobileDev\sd-site-induction> ionic cordova build android
> ionic-app-scripts.cmd build --target cordova --platform android
[15:53:49]  ionic-app-scripts 3.2.4 
[15:53:49]  build dev started ...
[15:53:50]  clean started ...
[15:53:50]  clean finished in 7 ms
[15:53:50]  copy started ...
[15:53:50]  deeplinks started ...
[15:53:50]  deeplinks finished in 451 ms
[15:53:50]  transpile started ...
[15:54:04]  transpile finished in 13.94 s
[15:54:04]  preprocess started ...
[15:54:04]  preprocess finished in 1 ms
[15:54:04]  webpack started ...
[15:54:04]  ionic-app-script task: "build" 
[15:54:04]  TypeError: Cannot read property 'emit' of undefined 
TypeError: Cannot read property 'emit' of undefined
    at WebpackObfuscator.apply (C:\MobileDev\sd-site-induction\node_modules\webpack-obfuscator\dist\index.js:22:24)
    at Compiler.apply (C:\MobileDev\sd-site-induction\node_modules\@ionic\app-scripts\node_modules\tapable\lib\Tapable.js:375:16)
    at webpack (C:\MobileDev\sd-site-induction\node_modules\@ionic\app-scripts\node_modules\webpack\lib\webpack.js:33:19)
    at C:\MobileDev\sd-site-induction\node_modules\@ionic\app-scripts\dist\webpack.js:132:24
    at new Promise (<anonymous>)
    at runWebpackFullBuild (C:\MobileDev\sd-site-induction\node_modules\@ionic\app-scripts\dist\webpack.js:113:12)
    at webpackWorker (C:\MobileDev\sd-site-induction\node_modules\@ionic\app-scripts\dist\webpack.js:70:19)
    at Object.webpack (C:\MobileDev\sd-site-induction\node_modules\@ionic\app-scripts\dist\webpack.js:29:12)
    at bundleWorker (C:\MobileDev\sd-site-induction\node_modules\@ionic\app-scripts\dist\bundle.js:13:22)
    at Object.bundle (C:\MobileDev\sd-site-induction\node_modules\@ionic\app-scripts\dist\bundle.js:6:12)
[ERROR] An error occurred while running subprocess ionic-app-scripts.

Any ideas why this is happening, or what the error means?

Thanks,
bengrah

主要语言
TypeScript
星标
930
派生
92
PR 合并指标
30 天内没有已合并 PR

环境准备

这个项目没有提供开发容器、Dockerfile 或贡献指南,环境需要你自己搭建:先看它的 README,通用步骤见我们的新手贡献指南。

从这里开始

  1. 先读完整个 Issue,再读项目的贡献指南。
  2. 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
  3. Fork 仓库,在一个分支上完成修改。
  4. 提交 Pull Request,并在描述里引用这个 Issue 编号。

javascript-obfuscator/webpack-obfuscator 的其他 Issue

查看 javascript-obfuscator/webpack-obfuscator 的全部 Issue

相似的 Issue

更多 TypeScript Issue

把新 issue 发到你的邮箱

精选适合新手参与的 GitHub issue 摘要。