Thanks to visit codestin.com
Credit goes to github.com

Skip to content

extending import api  #106

@enigma1

Description

@enigma1

I started using absurdjs with the importer but I noticed a couple of things.

  • The import api identifies by extension how to process a file and there is no default fallback
var ext = path.split('.').pop().toLowerCase();

So if the file has a non-handled extension I cannot use the import. Perhaps this can be changed having an extra parameter passed to the importer that can override the extension detection. Then if it is not present it will work as it does now.

  • The second thing I noticed was I needed to return a function in the module.exports for js files. In many cases I would like to return just an object like:
module.exports = {
  body: {
    padding: 0,
  }
};

instead of how it is currently

module.exports = function(api) {
api.add({
  body: {
    padding: 0,
  }
}};

should be simple to support both I think. Right now I use the node require to load the js file with the add api.

var AbsurdApi = require('absurd');
var absurd = AbsurdApi();
.....
var json = require(resource);
if( typeof json === 'function') json = json(absurd);

// compile or add+compile
......

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions