当前位置:  开发笔记 > 编程语言 > 正文

Use all files in a folder like a one big JS

如何解决《UseallfilesinafolderlikeaonebigJS》经验,为你挑选了0个好方法。

Is it possible to configure ESLint in WebStorm so functions, variables, etc. are parsed also from files in the same folder? In my build process, I concatenate all files in the same folders into big closures, for example:

   src/
      main/          ===> "main.js"
          api.js
          init.js
          ui.js
          constants.js
          .
          .
      renderer/      ===> "renderer.js"
          core.js
          events.js

I would like ESLint to treat all those files just like one, so I don't get "undef" errors for things that are defined.

If it can't be done automatically, I wouldn't mind to create a manual configuration specifying all those files if that is possible.

EDIT: Why I don't (can't) use modules? TLDR- legacy code and project requirements.

I need to minify all code. Current closure compiler can transpile ES6 into ES5, but I found some ES6 features very prone to produce broken code. So I am forced to use ES5.

As I need ES5. I would only be able to use require() to use modules. Now that's a problem, as require() is a dynamic include and it impacts performance on my context (big electron app for modest power devices)

So to answer @Avin_Kavish, I agree what I do is "technically non conforming", but at the end of the build process it is, because each folder has been grouped into a file. That file is the module or the script. To group the files I use a Gradle plugin https://github.com/eriwen/gradle-js-plugin, I inject a "closure header" and a "closure footer", and all the files in between in the order I want.

Despite the inconvenience, at the end I get super-compact nodeJS code, with all methods obfuscated, etc.

I ended up using @Patrick suggestion, thanks for that!

EDIT 2

WebPack + Electron-WebPack turned out to be what I was looking for.

BTW- I think the proper way to do this is if EsLint would allow a "folder" sourceType.

推荐阅读
U友50081205_653
这个屌丝很懒,什么也没留下!
DevBox开发工具箱 | 专业的在线开发工具网站    京公网安备 11010802040832号  |  京ICP备19059560号-6
Copyright © 1998 - 2020 DevBox.CN. All Rights Reserved devBox.cn 开发工具箱 版权所有