question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Including vendor dependencies in lazyloaded engines not working.

See original GitHub issue

With a clean ember-cli 2.12 and ember-engines 0.5.0 addon setting lazyloaded to true throws an error when trying to find a vendor file I have added to the vendorTree.

Running ember server on this repo will reproduce the issue. Changing the lazyloaded to false you will be able to build the app.

I would expect highlightjs and the shim be added to engines-vendor.js file.

The vendorTree can be found here

index.js file

module.exports = EngineAddon.extend({
  name: 'vendor-lazy-engine',
  lazyLoading: true,

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

    this.import('vendor/highlight.pack.js', {
      exports: {
        'highlight.js': [
          'default',
          'highlight',
          'highlightAuto',
          'highlightBlock'
        ]
      }
    });

    this.import('vendor/shims/highlightjs.js');
  },

  treeForVendor() {
    var tree = this._super.treeForVendor.apply(this, arguments);

   let hljsPath = path.parse(require.resolve('highlightjs'));
    
    let highlightTree = new Funnel(hljsPath.dir, {
      files: [hljsPath.base],
    });

    let vendorTree = MergeTrees([tree, highlightTree]);
    let debuggedTrees = debug(vendorTree, { name: 'vendorTree' });

    return debuggedTrees
  }
});

https://github.com/kiwiupover/vendor-lazy-engine

Issue Analytics

  • State:open
  • Created 6 years ago
  • Comments:7 (3 by maintainers)

github_iconTop GitHub Comments

2reactions
xmcommented, Feb 6, 2018

@SanthoshRaju91 according to https://ember-cli.com/extending/

For live reload when developing an addon use the isDevelopingAddon hook:

// addon index.js
isDevelopingAddon() {
  return true;
}
1reaction
geekygrapplercommented, Nov 16, 2017

@Turbo87 and I recently overcame this by using an in-repo-addon. For example we generated an in-repo addon: $ ember g in-repo-addon tl-mailcheck

Then added that addon as a dependency of the engine in it’s package.json:

  "ember-addon": {
    "paths": [
      "../tl-mailcheck"
    ]
  }

In the addons index.js:

const commonjs = require('rollup-plugin-commonjs');
const nodeResolve = require('rollup-plugin-node-resolve');
const Rollup = require('broccoli-rollup');


module.exports = {
  name: 'tl-mailcheck',

  isDevelopingAddon() {
    return true;
  },

  treeForAddon() {
    return new Rollup(`${__dirname}/lib`, {
      rollup: {
        entry: 'index.js',
        dest: 'tl-mailcheck.js',
        format: 'amd',
        moduleId: 'mailcheck',
        plugins: [
          nodeResolve(),
          commonjs(),
        ],
      },
    });
  },
};

Note mailcheck is CommonJS and we want amd, so we’re using rollup to convert it… And our entry file lib/index.js just has import and export.

import mailcheck from 'mailcheck';

export default mailcheck;

Mailcheck dependency remains in the package.json for the host app, but appears only in engine-vendor.js

Also, ember g in-reop-addon will add that addon as a dependency of your main host app, so make sure to remove it from the ember-addon part of your main package.json (or you’ll get the dep in vendor.js as well).

Read more comments on GitHub >

github_iconTop Results From Across the Web

Angular: Lazy-Loading Module not calling InjectionToken factory
I mean, it still has to go via the factory method that doesn't get called in the lazy-loaded module. Maybe it is because...
Read more >
Lazy Load Angular 9+ Components - Brian F Love
Learn from a Google Developer Expert: Lazy loading components with Angular 9+ just got a lot easier!
Read more >
Loading Third-Party JavaScript - web.dev
Third-party scripts are a predominant cause of performance slowdowns and are often caused by resources outside of your control. These issues can ...
Read more >
Lazy Loading - Spartacus Documentation - SAP
The result is that you do not have to load all the JavaScript of the full ... Customizing Lazy Loaded Modules; Preparing Libraries...
Read more >
A Guide to Managing Webpack Dependencies - Toptal
js, one of today's most popular JavaScript frameworks, module bundlers allow loading NPM modules in web browsers, and component-oriented libraries (like React) ...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found