azproduction / lmd

LMD - JavaScript Module-Assembler for building better web applications :warning: Project is no longer supported :warning:
http://azproduction.ru/lmd/
MIT License
449 stars 27 forks source link

sourcemap settings not working in mixins #141

Closed noway closed 11 years ago

noway commented 11 years ago

index.lmd.json:

{
    "name": "index build",
    "root": "../src",
    "output": "../dest/index.lmd.js",
    "www_root": "../",

    "modules": {
        "main": "js/main.js",
    },

    "main": "main",

    "pack": false,
}

dev.lmd.json:

{
    "name": "enabling source maps",
    "root": "../src",
    "output": "../scripts/index.lmd.js",
    "www_root": "../",

    "sourcemap": "../scripts/index.lmd.map",
    "sourcemap_inline": true,
    "sourcemap_www": "",
}

execute $ lmd build index+dev and project would compiled without sourcemaps.

Sourcemaps starts work only if move

    "sourcemap": "../scripts/index.lmd.map",
    "sourcemap_inline": true,
    "sourcemap_www": "",

to index.lmd.json

azproduction commented 11 years ago

Thare is reason for that. Mixins are "environment independant" and they does not know about config with which they are will be mixed (www paths and others). In case of sourcemap it knows fs path (sourcemap), relative www path (sourcemap_www) thats why you can not safely mix these properties with another config.

Instead of mix you can inherit one config from another - https://github.com/azproduction/lmd/tree/master/examples/features/extends

{
    "extends": "./index.lmd.json",
    "output": "../scripts/index.lmd.js",
    "sourcemap": "../scripts/index.lmd.map",
    "sourcemap_inline": true,
    "sourcemap_www": ""
}
noway commented 11 years ago

Oh, okay. I was trying do this that way, but i got error:

info:    Building `dev` (.lmd/dev.lmd.js(on))
info:    Writing LMD Package to /path/to/scripts/index.lmd.js
info:    Writing Source Map of Package to /path/to/scripts/index.lmd.map

path.js:360
        throw new TypeError('Arguments to path.join must be strings');
              ^
TypeError: Arguments to path.join must be strings
    at path.js:360:15
    at Array.filter (native)
    at Object.exports.join (path.js:358:36)
    at Stream.LmdBuilder.createSourceMap (/usr/lib/node_modules/lmd/bin/lmd_builder.js:1316:30)
    at Stream.LmdBuilder._build (/usr/lib/node_modules/lmd/bin/lmd_builder.js:1580:40)
    at Stream.LmdBuilder.build (/usr/lib/node_modules/lmd/bin/lmd_builder.js:1692:17)
    at /usr/lib/node_modules/lmd/bin/lmd_builder.js:69:40
    at process._tickCallback (node.js:415:13)
    at Function.Module.runMain (module.js:499:11)
    at startup (node.js:119:16)

After your answer I tried explicitly define www_root and root in dev.lmd.json and it compiled correct. This is bug or there's reason for that behavior? Anyway, please add more informative error message here.

Thanks.

azproduction commented 11 years ago

In node 0.10.x path.join become strict. Thats why this bug appears. I'll fix that, thanks!