Skip to content
This repository was archived by the owner on Aug 15, 2018. It is now read-only.

代码放二级目录,文件名有多个‘.’时,debug的require的id不正确 #830

Closed
niphor opened this issue Jun 13, 2014 · 9 comments
Labels
Milestone

Comments

@niphor
Copy link

niphor commented Jun 13, 2014

用的spm@3x

spm init新建个项目将主文件改到src/下面

src里建2个文件

one.js

//one.js
require('./one.two.three');

one.two.three.js直接是空白的好了

然后 spm build打包,得到的one-debug是这样的

define("bug/1.0.0/src/one-debug", ["bug/1.0.0/src/one.two.three-debug"], function(require, exports, module) {
  require("bug/1.0.0/src/one.two-debug.three");
});
define("bug/1.0.0/src/one.two.three-debug", [], function(require, exports, module) {});

one.two.three 被require时的名字变成了one.two-debug.three,而不是正确的one.two.three-debug

线上版因为没自动加-debug,所以没问题。如果用’-‘做分隔符则没问题

另外

define("one", ["two","three"], function(require, exports, module) {
  require("two");
});
define("two", ["three"], function(require, exports, module) {
  require("three");
});
define("three", [], function(require, exports, module) {});

明明 one.js只依赖two.js,打包出来之后,three.js也被添加到依赖中了,那么基本有可能上main入口的依赖那是非常非常长的...

我记得之前看到过这个issue,难道没解决?

@popomore
Copy link
Member

  1. debug 那个应该是个 bug
  2. 现在就是全依赖,但有优化空间 spm build 的全依赖逻辑 #820

@niphor niphor changed the title 代码放二级目录,文件名有多个‘.’时,打包出来的文件名字错误 代码放二级目录,文件名有多个‘.’时,debug的require的id不正确 Jun 13, 2014
@popomore
Copy link
Member

第一个没见到有问题,重新安装 spm 试试

@niphor
Copy link
Author

niphor commented Jun 14, 2014

@popomore

删了重装了,还能重现

D:\bug>spm -V
3.0.1

注意 一定得把代码放2级目录才能重现得出来,和package.json放一起是正常的。

代码
https://mega.co.nz/#!5dhGFIBK!n_02W7_WRb4bj249i9nFa89-dSr6SvIY_Ii_j1Ea3A4

@afc163 afc163 added the bug label Jun 19, 2014
@sorrycc
Copy link
Member

sorrycc commented Jun 26, 2014

试了下你提供的包,没有发现问题。

➜  bug-toomanydot  spm3 -V
3.0.2
➜  bug-toomanydot  spm3 build

          start: build [email protected]
      arguments: dest = dist
      arguments: cwd = $CWD
      arguments: include = relative
      arguments: ignore =
      arguments: idleading = {{name}}/{{version}}
      arguments: install = true
          found: [email protected]
          found: [email protected]
        package: analyse infomation
        package: dependencies:
        package: files: src/one.js,src/one.two.three.js
         output: files: src/one.js
          start: task clean
            end: task clean
          start: task build file src/one.js
          start: task build file src/one-debug.js
            end: task build file src/one-debug.js
            end: task build file src/one.js
          start: task build
            end: task build
         finish: build [email protected] (71ms)

➜  bug-toomanydot  cat dist/bug/1.0.0/src/one-debug.js
define("bug/1.0.0/src/one-debug", ["bug/1.0.0/src/one.two.three-debug"], function(require, exports, module) {
  require("bug/1.0.0/src/one.two.three-debug");
});
define("bug/1.0.0/src/one.two.three-debug", [], function(require, exports, module) {});

@niphor
Copy link
Author

niphor commented Jun 26, 2014

试了,还这样

test on Windows 7 sp1 32bit

删了重装spm

C:\Users\niphor>spm -V
3.0.2

运行build

H:\bug-toomanydot>spm install

        install: [email protected]
          fetch: [email protected]
        extract: C:\Users\niphor\.spm\cache\expect.js-0.3.1.tar.gz
      installed: sea-modules\expect.js\0.3.1
        install: [email protected]
          fetch: [email protected]
        extract: C:\Users\niphor\.spm\cache\seajs-2.2.1.tar.gz
      installed: sea-modules\seajs\2.2.1


H:\bug-toomanydot>spm build

          start: build [email protected]
      arguments: dest = dist
      arguments: cwd = $CWD
      arguments: include = relative
      arguments: ignore =
      arguments: idleading = {{name}}/{{version}}
      arguments: install = true
          found: [email protected]
          found: [email protected]
        package: analyse infomation
        package: dependencies:
        package: files: src/one.js,src/one.two.three.js
         output: files: src/one.js
          start: task clean
            end: task clean
          start: task build file src/one.js
          start: task build file src/one-debug.js
            end: task build file src/one.js
            end: task build file src/one-debug.js
          start: task build
            end: task build
         finish: build [email protected] (109ms)

js文件

define("bug/1.0.0/src/one-debug", ["bug/1.0.0/src/one.two.three-debug"], function(require, exports, module) {
  require("bug/1.0.0/src/one.two-debug.three");
});
define("bug/1.0.0/src/one.two.three-debug", [], function(require, exports, module) {});

@sorrycc
Copy link
Member

sorrycc commented Jun 26, 2014

重现了,wins 下确实有问题。

@popomore popomore mentioned this issue Jul 10, 2014
18 tasks
@popomore popomore added the build label Jul 14, 2014
@popomore
Copy link
Member

到时用新版跑下,我这 win 下测试用例都过了

@niphor
Copy link
Author

niphor commented Jul 16, 2014

@popomore 新版是哪个?
我更新了3.0.3 还是不行
更新到 3.1.0-rc4 还是不行

@popomore
Copy link
Member

还没发—
Sent from Mailbox for iPhone

On Wed, Jul 16, 2014 at 8:51 AM, Niphor [email protected] wrote:

@popomore 新版是哪个?
我更新了3.0.3 还是不行

更新到 3.1.0-rc4 还是不行

Reply to this email directly or view it on GitHub:
#830 (comment)

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

No branches or pull requests

4 participants