Git Product home page Git Product logo

Comments (4)

leoner avatar leoner commented on August 15, 2024

_使用define定义模块,但部分API的暴露还是通过向arale这个对象上挂载来实现的_ 这个完全是为了兼容性考虑的, 后续肯定不会这样做的. 因为现在不能消除其他代码对全局变量的引用, 所以原有如果污染全局变量的方法和接口并没有给限制死, 但是我们内部的引用一定严格的按照require的方式来. 不能直接引用全局变量了.

from aralejs.github.io.

lifesinger avatar lifesinger commented on August 15, 2024

我推荐采用方案二,可以看 1.2 中 dom 和 event 的组织
CommonJS 支持子模块开发方式,好处很明显:

  1. 子模块也是模块,无任何特殊性,遵循的规范一模一样
  2. 父模块里,声明了所依赖的子模块,任何子模块则只依赖父模块,看似循环依赖,其实 CommonJS 规范是支持循环依赖的,这种子模块拆分方式,目前在 YUI3 和 KISSY 里都有使用,很成熟
  3. 依赖打包等信息,存在于 js 代码本身里,不需要起来 Ant 或 Maven 的配置,保证了内聚和完备性

大家先看看 1.2 的代码?

from aralejs.github.io.

leoner avatar leoner commented on August 15, 2024

还有就是目前有些代码不光是直接引用arale.core, 有些是从arale.base开始引入的, 所以如果我们把某些对全局变量进行污染的模块给封装起来的话, 就不能保证这些项目的安全使用了. 所以我目前的想法是如果是对现有模块改造的话, 那么我们两种都可以支持, 但是我们可以通过其他手段(代码扫描)等方式协助用户在产品开发中去掉对全局变量的引用, 改为require的方式进行引用. 等到产品全部升级完毕后, 我们在把全局变量给去掉.

from aralejs.github.io.

lifesinger avatar lifesinger commented on August 15, 2024

基本已达成一致,采用 CommonJS 的方式,彻底模块化。

Arale 1.x 的问题,等以后需要做兼容层时再考虑。

from aralejs.github.io.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.