lundi 24 septembre 2018

Ember Fastboot / Ignore NPM Module

I first want to point out I'm crossposting from here:https://github.com/ember-fastboot/ember-cli-fastboot/issues/621 So far the issue hasn't gained any traction to opening to wider community.

I'm trying to make ember-cli-slick fastboot compliant. It uses slick.js from node_modules like so:

included: function(app) {
this._super.included(app);

app.import("node_modules/slick-carousel/slick/slick.js");

I'm attempting to get the treeforvendor working but not having much luck. I'm following the documentation here https://www.ember-fastboot.com/docs/addon-author-guide#third-party-dependencies but I suspect it's targetting bower rather than npm/node_modules.

treeForVendor(defaultTree) {        
    var browserVendorLib = new Funnel('node_modules/slick-carousel/slick/slick.js');    

    browserVendorLib = map(browserVendorLib, (content) => `if (typeof FastBoot === 'undefined') { ${content} }`);

    return new mergeTrees([defaultTree, browserVendorLib]);
  },

This results in the error:

Build Error (broccoli-persistent-filter:Mapper)

ENOTDIR: not a directory, scandir 'projectdir/tmp/broccoli_persistent_filtermapper-input_base_path-FOInixjr.tmp/'

I've also tried

  treeForVendor(defaultTree) {        
    var map = require("broccoli-stew").map;
    var Funnel = require("broccoli-funnel");
    const mergeTrees = require('broccoli-merge-trees');

    let tree=new Funnel('node_modules/slick-carousel/slick/', {
      destDir: 'slick-carousel',
      files: ['slick.js']
    })

    tree = map(tree, (content) => `if (typeof FastBoot === 'undefined') { ${content} }`);


    return new mergeTrees([defaultTree, tree]);
  },

This at least builds.. but then I get back to the Fastboot error

ReferenceError: jQuery is not defined at projectfolder/tmp/broccoli_merge_trees-output_path-8cGO0zCl.tmp/assets/node_modules/slick-carousel/slick/slick.js:25:1

I've created a clean and otherwise empty Ember addon project with just the import and treeforvendor functions to demonstrate the issue https://github.com/MrChriZ/ember-slicker




Aucun commentaire:

Enregistrer un commentaire