Giter Site home page Giter Site logo

more flexible timestamp mechanism. about seajs HOT 6 CLOSED

seajs avatar seajs commented on June 11, 2024
more flexible timestamp mechanism.

from seajs.

Comments (6)

lifesinger avatar lifesinger commented on June 11, 2024

场景一:

原来 require('biz/abc')
当 abc.js 有更新时,可以直接 require('biz/abc?t=20110425') 来更新
或者在 alias 配置里指定时间戳:

seajs.config({
  'alias' : {
    'abc': 'abc?t=20110425'
  }
});

from seajs.

lifesinger avatar lifesinger commented on June 11, 2024

场景二:

当业务模块里有一堆文件需要更新时,推荐在 alias 配置里统一维护:

seajs.config({
  'alias' : {
    'a': 'a?t=20110425',
    'b': 'b?t=20110425',
    'c': 'c?t=20110425',
    'd': 'd?t=20110425'
  }
});

一个应用对应一个配置,一般来说,这样应该够用了。

from seajs.

lifesinger avatar lifesinger commented on June 11, 2024

场景三:

假设 seajs 一直用 1.0.0. 这时部分模块已经有新版了,比如 jquery 1.6 正式出来了。在不更新 seajs 时,如何将 jquery 模块更新到 1.6 呢?建议的方式是:

  1. 下载 jquery 1.6,自行封装成 seajs 的模块,重命名为 jquery-1.6.0-debug.js 和 jquery-1.6.0.js

  2. 将上面两个文件放到 sea.js 所在目录

  3. 在需要使用 jquery 1.6 的 app 里,指定 alias:

    seajs.config({
    'alias' : {
    'jquery': 'jquery-1.6.0'
    }
    });

这样,该 app 下所有 require('jquery') 的地方,调用的将都是新版 jquery.
当然,也可以根据需求,自行决定 jquery 的 alias, 比如 jquery16 代码 1.6, 调用处再手动指定 require('jquery16')

from seajs.

lifesinger avatar lifesinger commented on June 11, 2024

场景四:

seajs 有更新了,比如从 1.0.0 更新到 1.1.0 了。这时请在页面中自行更新 sea.js 的引用路径。
这时要注意,如果自行更新过 modules,需要将自行更新过的 modules 复制过来,以保证所有 require 能正常引用到。

from seajs.

lifesinger avatar lifesinger commented on June 11, 2024

还有一种使用方式:

将 seajs 都部署到同一目录,全部带上版本号,比如:

libs/
  sea-1.0.0.js
  sea-1.1.0.js
  jquery-1.5.2.js
  jquery-1.6.0.js
  ...
  sea-config.js

在 sea-config.js 里,指定默认类库:

seajs.config({
  'alias': {
    'jquery': 'jquery-1.6.0',
    'underscore': 'underscore-1.2.0',
    ...
  }
});

每次更新时,可以根据实际情况,选择是否更新 sea-config.js

在页面中引用 sea.js 的方式:

<script src="path/to/libs/??sea-1.0.0.js,sea-config.js"></script>

或者自己手动打包好,比如将 sea-1.0.0.js 和 sea-config.js 合并为 sea.js, 所有页面都引用 sea.js 即可

from seajs.

lifesinger avatar lifesinger commented on June 11, 2024

从简单易用,和现有常规用法考虑,目前依旧采用下面的方式提供 seajs 的下载包:

seajs/
    0.9.0/
           sea.js
           sea-debug.js
           jquery.js
           jquery-debug.js
           underscore.js
           underscore-debug.js
           ...

    1.0.0/
           sea.js
           sea-debug.js
           jquery.js
           jquery-debug.js
           underscore.js
           underscore-debug.js
           ...

from seajs.

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.