Git Product home page Git Product logo

ember-cli-htmlbars's Introduction

Ember CLI HTMLBars

Build Status

Compatibility

  • Ember.js v4.12 or above
  • Ember CLI v4.12 or above
  • @embroider/compat 3.4.3 or above (optional)
  • Node.js v18 or above

Adding Custom Plugins

You can add custom plugins to be used during transpilation of the addon/ or addon-test-support/ trees of your addon (or the app/ and tests/ trees of an application) by registering a custom AST transform.

var SomeTransform = require('./some-path/transform');

module.exports = {
  name: 'my-addon-name',

  included: function() {
    // we have to wrap these in an object so the ember-cli
    // registry doesn't try to call `new` on them (new is actually
    // called within htmlbars when compiling a given template).
    this.app.registry.add('htmlbars-ast-plugin', {
      name: 'some-transform',
      plugin: SomeTransform
    });
    
    this._super.included.apply(this, arguments);
  }
};

Options for registering a plugin

  • name - String. The name of the AST transform for debugging purposes.
  • plugin - A function of type ASTPluginBuilder.
  • dependencyInvalidation - Boolean. A flag that indicates the AST Plugin may, on a per-template basis, depend on other files that affect its output.
  • cacheKey - function that returns any JSON-compatible value - The value returned is used to invalidate the persistent cache across restarts, usually in the case of a dependency or configuration change.
  • baseDir - () => string. A function that returns the directory on disk of the npm module for the plugin. If provided, a basic cache invalidation is performed if any of the dependencies change (e.g. due to a npm install/upgrade).

Implementing Dependency Invalidation in an AST Plugin

Plugins that set the dependencyInvalidation option to true can provide function for the plugin of type ASTDependencyPlugin as given below.

Note: the plugin function is invoked without a value for this in context.

import {ASTPluginBuilder, ASTPlugin} from "@glimmer/syntax/dist/types/lib/parser/tokenizer-event-handlers";

export type ASTDependencyPlugin = ASTPluginWithDepsBuilder | ASTPluginBuilderWithDeps;

export interface ASTPluginWithDepsBuilder {
  (env: ASTPluginEnvironment): ASTPluginWithDeps;
}

export interface ASTPluginBuilderWithDeps extends ASTPluginBuilder {
  /**
   * @see {ASTPluginWithDeps.dependencies} below.
   **/
  dependencies(relativePath): string[];
}

export interface ASTPluginWithDeps extends ASTPlugin {
  /**
   * If this method exists, it is called with the relative path to the current
   * file just before processing starts. Use this method to reset the
   * dependency tracking state associated with the file.
   */
  resetDependencies?(relativePath: string): void;
  /**
   * This method is called just as the template finishes being processed.
   *
   * @param relativePath {string} A relative path to the file that may have dependencies.
   * @return {string[]} paths to files that are a dependency for the given
   * file. Any relative paths returned by this method are taken to be relative
   * to the file that was processed.
   */
  dependencies(relativePath: string): string[];
}

Custom Template Compiler

You can still provide a custom path to the template compiler (e.g. to test custom template compiler tweaks in an application) by:

// ember-cli-build.js

module.exports = function(defaults) {
  let app = new EmberApp(defaults, {
    'ember-cli-htmlbars': {
      templateCompilerPath: `some_path/to/ember-template-compiler.js`,
    }
  });
};

Using as a Broccoli Plugin

var HtmlbarsCompiler = require('ember-cli-htmlbars');

var templateTree = new HtmlbarsCompiler('app/templates', {
  isHTMLBars: true,

  // provide the templateCompiler that is paired with your Ember version
  templateCompiler: require('./bower_components/ember/ember-template-compiler')
});

ember-cli-htmlbars's People

Contributors

bertdeblock avatar camerondubas avatar chancancode avatar chriseppstein avatar chriskrycho avatar dependabot-preview[bot] avatar dependabot-support avatar dependabot[bot] avatar dfreeman avatar ef4 avatar fivetanley avatar greenkeeperio-bot avatar hemp avatar kamalaknn avatar kategengler avatar locks avatar mansona avatar max avatar mehulkar avatar mixonic avatar ndekeister-us avatar pangratz avatar robinborst95 avatar rondale-sc avatar rwjblue avatar simonihmig avatar slexaxton avatar stefanpenner avatar tricknotes avatar turbo87 avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

ember-cli-htmlbars's Issues

Doesn't pick up `.handlebars` files

Our app is kinda old and has migrated through many build systems. All of our handlebars files use the .handlebars extension, but the current plugin only picks up .hbs files.

Add more tests around colocation feature

The initial colocation feature landed in #249, but we need to follow up with even more tests.

  • Add tests for template only
  • Add tests for backing non-native component class
  • Add tests for backing native class
  • Unit tests for the babel plugin (thanks @dfreeman!)
  • non-full app integration test confirming colocation broccoli plugin and babel plugin work together (#338)

Cannot find module 'broccoli-filter'

I am using ember cli and follow the instructions in the latest ember blogpost related to Handlebars 2.0 (http://emberjs.com/blog/2014/10/16/handlebars-update.html)

  npm uninstall --save broccoli-ember-hbs-template-compiler
  npm install --save-dev ember-cli-htmlbars
  rm -rf bower_components
  bower install --save handlebars#2.0.0
  bower install --save ember#canary
  bower install

and then I run ember serve and I get this stack trace

Cannot find module 'broccoli-filter'
 Error: Cannot find module 'broccoli-filter'
at Function.Module._resolveFilename (module.js:338:15)
at Function.Module._load (module.js:280:25)
at Module.require (module.js:364:17)
at require (module.js:380:17)
at Object.<anonymous> (/Users/jcope/inbox-dashboard/node_modules/ember-cli-htmlbars/index.js:1:76)
at Module._compile (module.js:456:26)
at Object.Module._extensions..js (module.js:474:10)
at Module.load (module.js:356:32)
at Function.Module._load (module.js:312:12)
at Module.require (module.js:364:17)

Remove depreciation for ember-cli>2.18

DEPRECATION: Overriding init without calling this._super is deprecated. Please call this._super.init && this._super.init.apply(this, arguments); addon: ember-cli-htmlbars

Overriding init without calling this._super is deprecated

seeing deprecation warning

DEPRECATION: Overriding init without calling this._super is deprecated. Please call `this._super.init && this._super.init.apply(this, arguments);` addon: `ember-cli-htmlbars`
    at Function.Addon.lookup (..../node_modules/ember-cli/lib/models/addon.js:896:27)

"ember-cli": "^2.4.0",

Pass AST Plugins to each `compile`

This would need to detect Ember version, and when possible avoid calling registerPlugin (which mutates closure scope and requires bizarre cache clearing shenanigans). Instead of registerPlugin we would pass the plugins directly to the compile invocation (in options.plugins.ast).

Related to #116.

Deprecation warnings triggered by addons could have more debug info

Is it possible for a deprecation warning to list the stack of addons that it was caused by?

It's all too easy for a deprecation to be caused by an addon loaded by an an addon, loaded by... you get the point. It's very labour intensive to find the addon that's loaded an old version of htmlbars (for example).

Write README.

As we approach Ember 1.10-beta.1 (where this will be required for HTMLBars usage within Ember CLI) we should likely add a more detailed README.

@rondale-sc - Do you think you might have some time for this in the next week or two?

Compatibility with ember-legacy-views

Since 1.0.4 I am seeing the following error when running ember serve:

Error: Assertion Failed: Using `{{view}}` or any path based on it ('app/templates/dashboard.hbs' @ L14:C10) has been removed in Ember 2.0

I do have the ember-legacy-views addon installed.
I don't see this anymore when downgrading to ember-cli-htmlbars 1.0.3

Babel Plugin Error

Description

When using ember-octane the bump from github:ember-cli/ember-cli-htmlbars#484f165c78aaed4fa5aa00d675ee7de905a8a47c to github:ember-cli/ember-cli-htmlbars#253503f1cda5bce173d65fd7b15de1f447cfa5e7 causes the error below.

I have tested all other changes and only this package causes the error

Console Error

Build Error (broccoli-persistent-filter:Babel > [Babel: account]) in account/components/basic-dropdown/content.js

Duplicate plugin/preset detected.
If you'd like to use two separate instances of a plugin,
they need separate names, e.g.

  plugins: [
    ['some-plugin', {}],
    ['some-plugin', {}, 'some unique name'],
  ]

It seems this error occurs when using this exact version of ember-cli-htmlbars with ember-engines as account/ is an in-repo-engine.

When I remove all engines from the package.json the build works again.

Log

=================================================================================

ENV Summary:

  TIME: Tue Sep 24 2019 00:25:55 GMT+0100 (British Summer Time)
  TITLE: ember
  ARGV:
  - /Users/devonte/.nvm/versions/node/v10.16.3/bin/node
  - /Users/devonte/Documents/Devonte/zenunu/node_modules/.bin/ember
  - serve
  EXEC_PATH: /Users/devonte/.nvm/versions/node/v10.16.3/bin/node
  TMPDIR: /var/folders/zp/9skf2wx96b37hdk3_rbd457m0000gn/T
  SHELL: /usr/local/bin/fish
  PATH:
  - /var/folders/zp/9skf2wx96b37hdk3_rbd457m0000gn/T/yarn--1569281110106-0.1583029301122636
  - /Users/devonte/Documents/Devonte/zenunu/node_modules/.bin
  - /Users/devonte/.config/yarn/link/node_modules/.bin
  - /Users/devonte/.nvm/versions/node/v10.16.3/libexec/lib/node_modules/npm/bin/node-gyp-bin
  - /Users/devonte/.nvm/versions/node/v10.16.3/lib/node_modules/npm/bin/node-gyp-bin
  - /Users/devonte/.nvm/versions/node/v10.16.3/bin/node_modules/npm/bin/node-gyp-bin
  - /Users/devonte/.nvm/versions/node/v10.16.3/bin
  - /Users/devonte/.gem/ruby/2.6.0/bin
  - /usr/local/Cellar/ruby/2.6.2/bin/
  - /usr/local/Cellar/ruby/2.6.2/lib/ruby/gems/2.6.0/bin
  - /usr/local/lib/ruby/gems/2.6.0/bin
  - /Users/devonte/go/bin
  - /usr/local/bin
  - /usr/bin
  - /bin
  - /usr/sbin
  - /sbin
  PLATFORM: darwin x64
  FREEMEM: 37142528
  TOTALMEM: 17179869184
  UPTIME: 2131985
  LOADAVG: 5.2919921875,5.50146484375,6.220703125
  CPUS:
  - Intel(R) Core(TM) i7-8750H CPU @ 2.20GHz - 2200
  - Intel(R) Core(TM) i7-8750H CPU @ 2.20GHz - 2200
  - Intel(R) Core(TM) i7-8750H CPU @ 2.20GHz - 2200
  - Intel(R) Core(TM) i7-8750H CPU @ 2.20GHz - 2200
  - Intel(R) Core(TM) i7-8750H CPU @ 2.20GHz - 2200
  - Intel(R) Core(TM) i7-8750H CPU @ 2.20GHz - 2200
  - Intel(R) Core(TM) i7-8750H CPU @ 2.20GHz - 2200
  - Intel(R) Core(TM) i7-8750H CPU @ 2.20GHz - 2200
  - Intel(R) Core(TM) i7-8750H CPU @ 2.20GHz - 2200
  - Intel(R) Core(TM) i7-8750H CPU @ 2.20GHz - 2200
  - Intel(R) Core(TM) i7-8750H CPU @ 2.20GHz - 2200
  - Intel(R) Core(TM) i7-8750H CPU @ 2.20GHz - 2200
  ENDIANNESS: LE
  VERSIONS:
  - ares: 1.15.0
  - brotli: 1.0.7
  - cldr: 35.1
  - http_parser: 2.8.0
  - icu: 64.2
  - modules: 64
  - napi: 4
  - nghttp2: 1.39.2
  - node: 10.16.3
  - openssl: 1.1.1c
  - tz: 2019a
  - unicode: 12.1
  - uv: 1.28.0
  - v8: 6.8.275.32-node.54
  - zlib: 1.2.11

ERROR Summary:

  - broccoliBuilderErrorStack: Error: Duplicate plugin/preset detected.
If you'd like to use two separate instances of a plugin,
they need separate names, e.g.

  plugins: [
    ['some-plugin', {}],
    ['some-plugin', {}, 'some unique name'],
  ]
    at assertNoDuplicates (/Users/devonte/Documents/Devonte/zenunu/node_modules/ember-cli-babel/node_modules/@babel/core/lib/config/config-descriptors.js:205:13)
    at createDescriptors (/Users/devonte/Documents/Devonte/zenunu/node_modules/ember-cli-babel/node_modules/@babel/core/lib/config/config-descriptors.js:114:3)
    at createPluginDescriptors (/Users/devonte/Documents/Devonte/zenunu/node_modules/ember-cli-babel/node_modules/@babel/core/lib/config/config-descriptors.js:105:10)
    at alias (/Users/devonte/Documents/Devonte/zenunu/node_modules/ember-cli-babel/node_modules/@babel/core/lib/config/config-descriptors.js:63:49)
    at cachedFunction (/Users/devonte/Documents/Devonte/zenunu/node_modules/ember-cli-babel/node_modules/@babel/core/lib/config/caching.js:33:19)
    at plugins.plugins (/Users/devonte/Documents/Devonte/zenunu/node_modules/ember-cli-babel/node_modules/@babel/core/lib/config/config-descriptors.js:28:77)
    at mergeChainOpts (/Users/devonte/Documents/Devonte/zenunu/node_modules/ember-cli-babel/node_modules/@babel/core/lib/config/config-chain.js:319:26)
    at /Users/devonte/Documents/Devonte/zenunu/node_modules/ember-cli-babel/node_modules/@babel/core/lib/config/config-chain.js:283:7
    at buildRootChain (/Users/devonte/Documents/Devonte/zenunu/node_modules/ember-cli-babel/node_modules/@babel/core/lib/config/config-chain.js:68:29)
    at loadPrivatePartialConfig (/Users/devonte/Documents/Devonte/zenunu/node_modules/ember-cli-babel/node_modules/@babel/core/lib/config/partial.js:85:55)
  - code: [undefined]
  - codeFrame: Duplicate plugin/preset detected.
If you'd like to use two separate instances of a plugin,
they need separate names, e.g.

  plugins: [
    ['some-plugin', {}],
    ['some-plugin', {}, 'some unique name'],
  ]
  - errorMessage: account/components/basic-dropdown/content.js: Duplicate plugin/preset detected.
If you'd like to use two separate instances of a plugin,
they need separate names, e.g.

  plugins: [
    ['some-plugin', {}],
    ['some-plugin', {}, 'some unique name'],
  ]
        in /var/folders/zp/9skf2wx96b37hdk3_rbd457m0000gn/T/broccoli-2434813No9clUHwWX/out-0891-funnel_funnel_addon_js
        at broccoli-persistent-filter:Babel > [Babel: account] (Babel: account)
  - errorType: Build Error
  - location:
    - column: [undefined]
    - file: account/components/basic-dropdown/content.js
    - line: [undefined]
    - treeDir: /var/folders/zp/9skf2wx96b37hdk3_rbd457m0000gn/T/broccoli-2434813No9clUHwWX/out-0891-funnel_funnel_addon_js
  - message: account/components/basic-dropdown/content.js: Duplicate plugin/preset detected.
If you'd like to use two separate instances of a plugin,
they need separate names, e.g.

  plugins: [
    ['some-plugin', {}],
    ['some-plugin', {}, 'some unique name'],
  ]
        in /var/folders/zp/9skf2wx96b37hdk3_rbd457m0000gn/T/broccoli-2434813No9clUHwWX/out-0891-funnel_funnel_addon_js
        at broccoli-persistent-filter:Babel > [Babel: account] (Babel: account)
  - name: BuildError
  - nodeAnnotation: Babel: account
  - nodeName: broccoli-persistent-filter:Babel > [Babel: account]
  - originalErrorMessage: Duplicate plugin/preset detected.
If you'd like to use two separate instances of a plugin,
they need separate names, e.g.

  plugins: [
    ['some-plugin', {}],
    ['some-plugin', {}, 'some unique name'],
  ]
  - stack: Error: Duplicate plugin/preset detected.
If you'd like to use two separate instances of a plugin,
they need separate names, e.g.

  plugins: [
    ['some-plugin', {}],
    ['some-plugin', {}, 'some unique name'],
  ]
    at assertNoDuplicates (/Users/devonte/Documents/Devonte/zenunu/node_modules/ember-cli-babel/node_modules/@babel/core/lib/config/config-descriptors.js:205:13)
    at createDescriptors (/Users/devonte/Documents/Devonte/zenunu/node_modules/ember-cli-babel/node_modules/@babel/core/lib/config/config-descriptors.js:114:3)
    at createPluginDescriptors (/Users/devonte/Documents/Devonte/zenunu/node_modules/ember-cli-babel/node_modules/@babel/core/lib/config/config-descriptors.js:105:10)
    at alias (/Users/devonte/Documents/Devonte/zenunu/node_modules/ember-cli-babel/node_modules/@babel/core/lib/config/config-descriptors.js:63:49)
    at cachedFunction (/Users/devonte/Documents/Devonte/zenunu/node_modules/ember-cli-babel/node_modules/@babel/core/lib/config/caching.js:33:19)
    at plugins.plugins (/Users/devonte/Documents/Devonte/zenunu/node_modules/ember-cli-babel/node_modules/@babel/core/lib/config/config-descriptors.js:28:77)
    at mergeChainOpts (/Users/devonte/Documents/Devonte/zenunu/node_modules/ember-cli-babel/node_modules/@babel/core/lib/config/config-chain.js:319:26)
    at /Users/devonte/Documents/Devonte/zenunu/node_modules/ember-cli-babel/node_modules/@babel/core/lib/config/config-chain.js:283:7
    at buildRootChain (/Users/devonte/Documents/Devonte/zenunu/node_modules/ember-cli-babel/node_modules/@babel/core/lib/config/config-chain.js:68:29)
    at loadPrivatePartialConfig (/Users/devonte/Documents/Devonte/zenunu/node_modules/ember-cli-babel/node_modules/@babel/core/lib/config/partial.js:85:55)

=================================================================================

Explanation needed on how to use this.

I followed the instructions found in the blog post, using Ember CLI 0.1.2

npm uninstall --save-dev broccoli-ember-hbs-template-compiler
npm install --save-dev ember-cli-htmlbars
rm -rf bower_components
bower install --save handlebars#2.0.0
bower install --save ember#canary
bower install

And changed config/environment.js so that HTMLBars is enabled.

EmberENV: {
  FEATURES: {
    HTMLBars: true
  }
}

When compiling a template, the addon is called correctly and, from what I can tell, produces a valid function. The problem seems to occur when Broccoli does its thing, because there's an extra paren added to the eval'ed string in the built handlebars.js.

I'm sure there's a better way to explain it :) Am I doing something wrong? Thanks.

Error: EEXIST: file already exists, symlink...

Environment: node 6.5.0, ember-cli 2.10.0, ember-cli-htmlbars 1.1.1

When I run ember build, I get

Build failed.
The Broccoli Plugin: [TemplateCompiler] failed with:
Error: EEXIST: file already exists, symlink '/Users/jamesarosen/Code/style-guide/node_modules/ember-freestyle/app/templates/components/freestyle-palette-item.js' -> '/Users/jamesarosen/Code/style-guide/tmp/template_compiler-output_path-PCqYFUPh.tmp/dummy/templates/components/freestyle-palette-item.js'
    at Error (native)
    at Object.fs.symlinkSync (fs.js:1054:18)
    at FSMonitor._measure (/Users/jamesarosen/Code/style-guide/node_modules/heimdalljs-fs-monitor/index.js:66:21)
    at Object.symlinkSync (/Users/jamesarosen/Code/style-guide/node_modules/heimdalljs-fs-monitor/index.js:82:30)
    at symlink (/Users/jamesarosen/Code/style-guide/node_modules/symlink-or-copy/index.js:79:14)
    at symlinkOrCopySync (/Users/jamesarosen/Code/style-guide/node_modules/symlink-or-copy/index.js:55:5)
    at TemplateCompiler.Filter._handleFile (/Users/jamesarosen/Code/style-guide/node_modules/broccoli-persistent-filter/index.js:169:12)
    at TemplateCompiler.<anonymous> (/Users/jamesarosen/Code/style-guide/node_modules/broccoli-persistent-filter/index.js:146:23)
    at /Users/jamesarosen/Code/style-guide/node_modules/promise-map-series/index.js:11:14
    at tryCatch (/Users/jamesarosen/Code/style-guide/node_modules/rsvp/dist/rsvp.js:538:12)

The broccoli plugin was instantiated at:
    at TemplateCompiler.Plugin (/Users/jamesarosen/Code/style-guide/node_modules/broccoli-plugin/index.js:7:31)
    at TemplateCompiler.Filter [as constructor] (/Users/jamesarosen/Code/style-guide/node_modules/broccoli-persistent-filter/index.js:60:10)
    at new TemplateCompiler (/Users/jamesarosen/Code/style-guide/node_modules/ember-cli-htmlbars/index.js:20:10)
    at TemplateCompiler (/Users/jamesarosen/Code/style-guide/node_modules/ember-cli-htmlbars/index.js:12:12)
    at Object.toTree (/Users/jamesarosen/Code/style-guide/node_modules/ember-cli-htmlbars/ember-addon-main.js:32:34)
    at /Users/jamesarosen/Code/style-guide/node_modules/ember-cli-preprocess-registry/preprocessors.js:180:26
    at Array.forEach (native)
    at processPlugins (/Users/jamesarosen/Code/style-guide/node_modules/ember-cli-preprocess-registry/preprocessors.js:178:11)
    at module.exports.preprocessTemplates (/Users/jamesarosen/Code/style-guide/node_modules/ember-cli-preprocess-registry/preprocessors.js:161:10)
    at EmberAddon.EmberApp._processedTemplatesTree (/Users/jamesarosen/Code/style-guide/node_modules/ember-cli/lib/broccoli/ember-app.js:836:48)

freestyle-palette-item is provided by ember-freestyle, but I override that template in my addon's tests/dummy/app/templates/components/freestyle-palette-item.hbs. The original and my override both use .hbs, so I don't think the problem is having two different compilers conflicting on an output. (See ember-cli/ember-cli#3413)

Emit used components in a template

Is there a way to emit or list the used components in a template?

Basically, in my application that has an addon with 1000 components, I only want to include the components that I actually use in the application.

My thought is that if I can get a list of components used, then I can filter the tree in addon hooks.

I see in the compiled form of a template:

statements: [["content", "outlet", ["loc", [null, [11, 0], [11, 10]]]], ["content", "component-one-from-addon", ["loc", [null, [14, 0], [14, 19]]]], ["content", "component-two-from-addon", ["loc", [null, [17, 0], [17, 17]]]]],

Is there any registry of used components?
When and where would that be available at build time?

This may be related to #47
Also related: http://discuss.emberjs.com/t/how-to-include-only-a-subset-of-the-files-from-an-addon/9099

Issues following Readme instructions for precompiling in an addon

I'm trying to precompile HTMLBars template strings as described in the readme. However, I've come across two problems.

  1. find is undefined - this is fairly easy to solve with native JS
  2. the htmlbarsPlugin variable is equal to { name: 'ember-cli-htmlbars', ext: 'hbs', toTree: [Function] } and does not have a precompile function.

The code I am referring to is:

module.exports = {
  name: 'my-addon-name',

  setupPreprocessorRegistry: function(type, registry) {
    // Error 1 - find is not a function
    var htmlbarsPlugin = registry.load('template').find(function(plugin) {
      return plugin.name === 'ember-cli-htmlbars';
    });

    // Error 2 - precompile is not a function
    var precompiled = htmlbarsPlugin.precompile("{{my-component}}");
  }
};

Ember CLI version is 0.2.5. Ember version is 1.12.0.

Warning when registering plugin using baseDir if broccoli-rollup is installed

When attempting to add a plugin

setupPreprocessorRegistry(type, registry) {
    registry.add('htmlbars-ast-plugin', {
      baseDir() {
        return __dirname;
      },
    });
  },

if broccoli-rollup is installed then when running ember serve I get the message:
Warning: failed to stat /preprocess-rollup/node_modules/broccoli-rollup/tmp/rollup-input_base_path-6obEeBLr.tmp/0

If I remove broccoli-rollup or remove the baseDir

setupPreprocessorRegistry(type, registry) {
    registry.add('htmlbars-ast-plugin', {});
},

Then no warning is printed.

This is reproducible in a brand new addon like https://github.com/jrjohnson/preprocess-rollup (addon doesn't do anything and the plugin itself won't work since it doesn't exist, bu the message is obvious.

I'm running into this while working on FortAwesome/ember-fontawesome#21

AST transforms no longer register in tests

// index.js
setupPreprocessorRegistry: function(type, registry) {
    var VGet = require('./htmlbars-plugins/v-get');
    registry.add('htmlbars-ast-plugin', {
      name: "v-get",
      plugin: VGet
    });
}
// tests/integration/helpers/v-get-test.js
moduleForComponent('helper:v-get', 'Integration | Helper | v-get', {
  integration: true
});
not ok 47 Chrome 52.0 - Integration | Helper | v-get: it renders
    ---
        actual: >
            null
        stack: >
            Error: Assertion Failed: A helper named 'v-get' could not be found
                at new Error (native)
                at Error.EmberError (http://localhost:7357/assets/vendor.js:22077:21)
                at Object.Ember.default.assert (http://localhost:7357/assets/vendor.js:15178:13)
                at inline (http://localhost:7357/assets/vendor.js:17368:11)
                at Object.render (http://localhost:7357/assets/tests.js:386:11)
                at renderHTMLBarsTemplate (http://localhost:7357/assets/vendor.js:17861:21)
                at renderView (http://localhost:7357/assets/vendor.js:17828:16)
                at renderView (http://localhost:7357/assets/vendor.js:46828:5)
                at Class.render (http://localhost:7357/assets/vendor.js:46849:7)
                at EmberRenderer_createElement [as createElement] (http://localhost:7357/assets/vendor.js:48973:14)
        message: >
            Died on test #1     at testWrapper (http://localhost:7357/assets/test-support.js:12261:11)
                at test (http://localhost:7357/assets/test-support.js:12274:39)
                at Module.callback (http://localhost:7357/assets/tests.js:341:24)
                at Module.exports (http://localhost:7357/assets/vendor.js:131:32)
                at requireModule (http://localhost:7357/assets/vendor.js:30:18)
                at s (http://localhost:7357/assets/vendor.js:76651:143)
                at s (http://localhost:7357/assets/vendor.js:76651:123): Assertion Failed: A helper named 'v-get' could not be found
        Log: |

@rwjblue has noted that this may be related to:

PR: adopted-ember-addons/ember-cp-validations#279
Build: https://travis-ci.org/offirgolan/ember-cp-validations/jobs/148121235

this._super is deprecated for ember-cli v2.6.2

After upgrading to ember-cli v2.6.2 I get:

DEPRECATION: Overriding init without calling this._super is deprecated. Please call 'this._super.init && this._super.init.apply(this, arguments);' addon: 'ember-cli-htmlbars'

at Function.Addon.lookup (frontend/node_modules/ember-cli/lib/models/addon.js:896:27)

Hammer actions aren't recognized

Hello,

I have noticed ignorance of Hammer events - aren't recognised/initiated pan/tap/swipe actions. I haven't dived deeper due to the lack of time. The issue has been resolved with setting fixed 0.7.4 version. I'm using Hammer 2.0.4, ember 1.10 and ember-cli 0.1.5. Detected in Chrome browser.

Regards

Cannot find module 'fs-copy-file-sync' on Octane

Hi!

Our app is aligned with the latest Octane blueprint.

It seems to install ember-cli-htmlbars from @rwjblue's colocation branch.

Our CI builds are crashing with this:

  - stack: Error: Cannot find module 'fs-copy-file-sync'
    at Function.Module._resolveFilename (internal/modules/cjs/loader.js:582:15)
    at Function.Module._load (internal/modules/cjs/loader.js:508:25)
    at Module.require (internal/modules/cjs/loader.js:637:17)
    at require (internal/modules/cjs/helpers.js:22:18)
    at Object.<anonymous> (/opt/atlassian/pipelines/agent/build/node_modules/ember-cli-htmlbars/lib/colocated-broccoli-plugin.js:5:22)
    at Module._compile (internal/modules/cjs/loader.js:701:30)
    at Object.Module._extensions..js (internal/modules/cjs/loader.js:712:10)
    at Module.load (internal/modules/cjs/loader.js:600:32)
    at tryModuleLoad (internal/modules/cjs/loader.js:539:12)
    at Function.Module._load (internal/modules/cjs/loader.js:531:3)

This issue cannot be reliably reproduced on developer machines.

Network shows the colocation-refactor branch to be more recent, but I dunno if it's stable.

template-specific cache invalidation for ast plugins

AST Plugins may make different changes to a template based on other state of the project. (For instance, a plugin might rewrite css classes based on content within css files.)

Right now, the cacheKey option is invoked during plugin registration. This lets the ast addon invalidate based on configuration, but not based on the application state specific to the template.

The template path can be connected to the cache key here:

return this.optionsHash() + Filter.prototype.cacheKeyProcessString.call(this, string, relativePath);

I'd like to submit a fix for this. My plan is to delay invocation of cacheKey() until cacheKeyProcessString is invoked. The cacheKey function provided by the addon that provides the ast plugin, would be passed the path to the template file.

0.7.0 breaks ember 1.9.1 apps?

I think I'm seeing that 0.7.0 won't work with an Ember 1.9.1 app anymore. Somebody following the upgrade instructions from 1.8 to 1.9 is going to end up with 0.7.0 and a broken install.

Possibly this should have received a major version bump?

The minor update from `0.7.9` to `0.7.10` broke my ember app

Hey guys, I have just discovered that the 0.7.10 update was causing a problem to my ember app. Since it's a minor update, I think it wasn't supposed to break.

Here's the problem:

  • The app loads fine for the first time
  • When I make some change and the page reloads itself with the live-reload extension, nothing is loaded inside my ember-view.

screen shot 2015-08-20 at 17 30 46

I don't know what information would be usefull for you guys to debug. Let me know what information you need.

Hashtree is not defined

Reference error: Hashtree is not defined
at C:\Windows\System32\node_modules\ember-cli-htmlbars\node_modules\broccoli-filter\node_modules\broccoli-kitchen-sink-helpers

Object #<Registry> has no method 'remove'

Issue is with this line in ember-addon-main.js:
15: app.registry.remove('template', 'broccoli-ember-hbs-template-compiler');

ember-cli version 0.0.44
ember version 1.9.0
ember-data version 1.0.0-beta.12

Commenting out this line solved the issue.

Parallel compilations appears to troll hash-for-dep cache

I noticed that rebuild time for a particular addon (with a lot of handlebars AST transforms) recently ballooned from a few seconds to 80-90 seconds.

It appears that something (I'm guessing the parallel compile) is causing hash-for-dep to be invoked as multiple modules, instead of a single module. Since the hash-for-dep cache is module scoped, invoking as multiple modules means that the cache is effectively useless.

EDIT: The cache was only created once in [email protected]. When I upgraded to 1.0.3 is when the multiple caches thing happened. There were other things also upgraded though at the same time.

cc @stefanpenner

Deprecation warning in latest ember-cli

DEPRECATION: Overriding init without calling this._super is deprecated. Please call this._super.init && this._super.init.apply(this, arguments); addon: ember-cli-htmlbars

Compiler added to app registry but not to addons

app.registry.add only adds it to the app registry, which means we can't use HTMLbars if at least one of our addons has templates.

Adding registry.add('template', 'ember-cli-htmlbars', ['hbs', 'handlebars']); to ember-cli's setupRegistry only fixes this for Handlebars since this will cause it to go directly to ember-cli-htmlbars/index.js which is the precompiler that assumes HTMLbars is disabled.

Parsing error does not output filename

Hi! I followed this post to test htmlbars (http://reefpoints.dockyard.com/2014/11/30/htmlbars_calling_all_testers.html) and it seems like a have some corrupt templates.

The error message does state the concrete bad tag, but unfortunately does not show the filename in which the error was found:

Closing tag `div` (on line 62) did not match last open tag `form`.
Error: Closing tag `div` (on line 62) did not match last open tag `form`.
    at HTMLProcessor.tokenHandlers.EndTag (/Users/istefo/Development/ddfClient/node_modules/ember-cli-htmlbars/node_modules/htmlbars/dist/cjs/htmlbars-compiler/html-parser/token-handlers.js:120:13)
    at HTMLProcessor.acceptToken (/Users/istefo/Development/ddfClient/node_modules/ember-cli-htmlbars/node_modules/htmlbars/dist/cjs/htmlbars-compiler/parser.js:35:43)
    at forEach (/Users/istefo/Development/ddfClient/node_modules/ember-cli-htmlbars/node_modules/htmlbars/dist/cjs/htmlbars-compiler/utils.js:10:16)
    at HTMLProcessor.nodeHandlers.content (/Users/istefo/Development/ddfClient/node_modules/ember-cli-htmlbars/node_modules/htmlbars/dist/cjs/htmlbars-compiler/html-parser/node-handlers.js:65:12)
    at HTMLProcessor.acceptNode (/Users/istefo/Development/ddfClient/node_modules/ember-cli-htmlbars/node_modules/htmlbars/dist/cjs/htmlbars-compiler/parser.js:30:39)
    at HTMLProcessor.nodeHandlers.program (/Users/istefo/Development/ddfClient/node_modules/ember-cli-htmlbars/node_modules/htmlbars/dist/cjs/htmlbars-compiler/html-parser/node-handlers.js:22:12)
    at HTMLProcessor.acceptNode (/Users/istefo/Development/ddfClient/node_modules/ember-cli-htmlbars/node_modules/htmlbars/dist/cjs/htmlbars-compiler/parser.js:30:39)
    at preprocess (/Users/istefo/Development/ddfClient/node_modules/ember-cli-htmlbars/node_modules/htmlbars/dist/cjs/htmlbars-compiler/parser.js:9:51)
    at compileSpec (/Users/istefo/Development/ddfClient/node_modules/ember-cli-htmlbars/node_modules/htmlbars/dist/cjs/htmlbars-compiler/compiler.js:58:13)
    at TemplateCompiler.processString (/Users/istefo/Development/ddfClient/node_modules/ember-cli-htmlbars/index.js:26:56)

dedent version of `hbs`?

Is there appetite for a version of hbs that dedents the template string?

I find myself often doing things like

layout: hbs(dedent`
  greeting: <span>{{greeting}}</span>
`)

with an npm package, but it always feels like extra work & is most of the time (always?) what I want.

You can see in Ember Animated's codebase Ed's forced to manually dedent the strings because he never got around to installing dedent, which kinda sucks.

Wondering if we could export an hbsd or hbsDedent tag that does this automatically.

layout: hbsDedent`
  greeting: <span>{{greeting}}</span>
`)

Watcha think?

DEPRECATION: Overriding init without calling this._super is deprecated. Please call `this._super.init && this._super.init.apply(this, arguments);` addon: `ember-cli-htmlbars`

DEPRECATION: Overriding init without calling this._super is deprecated. Please call `this._super.init && this._super.init.apply(this, arguments);` addon: `ember-cli-htmlbars`
    at Function.Addon.lookup (/Users/dillonwelch/Code/Work/currica/nsqip-web-ember/node_modules/ember-cli/lib/models/addon.js:896:27)
DEPRECATION: Overriding init without calling this._super is deprecated. Please call `this._super.init && this._super.init.apply(this, arguments);` addon: `ember-cli-htmlbars`
    at Function.Addon.lookup (/Users/dillonwelch/Code/Work/currica/nsqip-web-ember/node_modules/ember-cli/lib/models/addon.js:896:27)
DEPRECATION: Overriding init without calling this._super is deprecated. Please call `this._super.init && this._super.init.apply(this, arguments);` addon: `ember-cli-htmlbars`
    at Function.Addon.lookup (/Users/dillonwelch/Code/Work/currica/nsqip-web-ember/node_modules/ember-cli/lib/models/addon.js:896:27)

This is using Ember 2.4.3 and ember-cli-htmlbars 1.0.8

Modifying ast plugin should bust cache

Given an addon that has an htmlbars-ast-plugin, cached htmlbars files should be busted when the plugin is modifyed. This does not happen. I have to delete the async cache.

// Changing this file should bust the cache
var ReWriteStuff = require('re-write-stuff');

module.exports = {
  name: 'my-addon',
  setupPreprocessorRegistry: function() {
    registry.add('htmlbars-ast-plugin', {
      name: 're-write-stuff',
      plugin: ReWriteStuff
    });
  }
};

Extra paren output in compiled templates

As far as I can tell, if I flip HTMLBars on, I get a rogue paren at the end of the compiled templates. Probably a difference in the compilation output.

Example (more or less empty application.hbs, though happens on bigger files too):

define("dashboard-ui/templates/application", 
  ["exports"],
  function(__exports__) {
    "use strict";
    __exports__["default"] = function() {
      function build(dom) {
        var el0 = dom.createDocumentFragment();
        var el1 = dom.createTextNode("");
        dom.appendChild(el0, el1);
        var el1 = dom.createTextNode("\n");
        dom.appendChild(el0, el1);
        return el0;
      }
      var cachedFragment;
      return function template(context, env, contextualElement) {
        var dom = env.dom, hooks = env.hooks;
        dom.detectNamespace(contextualElement);
        if (cachedFragment === undefined) {
          cachedFragment = build(dom);
        }
        var fragment = dom.cloneNode(cachedFragment, true);
        dom.repairClonedNode(fragment,[0]);
        var morph0 = dom.createMorphAt(fragment,0,1,contextualElement);
        hooks.content(morph0, "liquid-outlet", context, [], {context:context,escaped:true,morph:morph0}, env);
        return fragment;
      };
    }()

); // <----- This doesn't go to anything 


  });//# sourceURL=dashboard-ui/templates/application.js

Add License File?

Just wondering whether this package is covered under MIT license. If so, would you mind adding a license file?

Thanks!

Merging compiled templates into app.js

I have some common components and templates that I need to include in multiple Ember-CLI apps. Unless there is a way to specify that my common/templates folder also be watched, just like app/templates, I figured I would need to use this to do it in my Brocfile myself. I've currently got this:

var commonTemplates = new HtmlbarsCompiler('../common/templates/components', {
  isHTMLBars: true,

  // provide the templateCompiler that is paired with your Ember version
  templateCompiler: require('./bower_components/ember/ember-template-compiler')
});

// Merge the app tree and all of our common assets
module.exports = mergeTrees([app.toTree(), commonImages, commonFonts, commonTemplates]);

This is copying each template into it's own js file in dist/ though. How can I make them be added to app.js, like the ones from the app folder?

Also, I know it's not related to this library, but I'll need a way of grabbing all the components and other ember files and doing similar things, if you could point me in the right direction please.

"unreachable" error in 3.0.0 with "option" argument

After upgrading to ember-cli-htmlbars 3.0.0, the following code:

{{#each sortedOptions as |option|}}
{{/each}}

Throws this error:

util.js:16 Uncaught Error: unreachable
    at unreachable (util.js:16)
    at Object.evaluate (runtime.js:1128)
    at AppendOpcodes.evaluate (runtime.js:46)
    at LowLevelVM.evaluateSyscall (runtime.js:2896)
    at LowLevelVM.evaluateInner (runtime.js:2868)
    at LowLevelVM.evaluateOuter (runtime.js:2860)
    at VM.next (runtime.js:4788)
    at TemplateIteratorImpl.next (runtime.js:4880)
    at RootState.render (ember-glimmer.js:4081)
    at TransactionRunner.runInTransaction (ember-metal.js:406)

It works if I change it to:

{{#each sortedOptions as |opt|}}
{{/each}}

It seems that the mere presence of an argument named option makes it trip up - it doesn't matter if I use it.

Implement stable caching (and tests) for colocation compilation.

The main implementation in #249 did the semi-naive thing of building the output tree every time without caching. Before we can enable this by default for all scenarios, we must implement a caching system that ensures the output tree is stable if none of the things changed here are modified.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.