Code Monkey home page Code Monkey logo

ember-element-helper's Introduction

ember-element-helper

Build Status

Dynamic element helper for Glimmer templates.

This addon provides a polyfill high fidelity reference implementation of RFC #389, including the proposed amendments in RFC PR #620.

Please note that while RFC #389 has been approved, it has not been implemented in Ember.js yet. As such, the feature is still subject to change based on implementation feedback.

When this feature is implemented in Ember.js, we will release a 1.0 version of this addon as a true polyfill for the feature, allowing the feature to be used on older Ember.js versions and be completely inert on newer versions where the official implementation is available.

Compatibility

  • Ember.js v3.28 or above
  • Ember CLI v3.28 or above
  • Node.js v12 or above

Limitations

This implementation has the following known limitations:

  • By default, an auto-generated id attribute will be added to the element (e.g. id="ember123"). It is possible to override this by providing an id attribute when invoking the component (e.g. <Tag id="my-id" />). However, it is not possible to remove the id attribute completely. The proposed helper will not have this behavior, as such this should not be relied upon (e.g. in CSS and qunit-dom selectors).

  • The element will have an ember-view class (i.e. class="ember-view"). This is in addition and merged with the class attribute provided when invoking the component (e.g. <Tag class="my-class" /> will result in something like <div class="ember-view my-class" />). It is not possible to remove the ember-view class. The proposed helper will not have this behavior, as such this should not be relied upon (e.g. in CSS and qunit-dom selectors).

  • In Ember versions before 3.11, modifiers cannot be passed to the element, even when addons such as the modifier manager and on modifier polyfills are used. Doing so requires RFC #435 which is first available on Ember 3.11. This is an Ember.js limitation, unrelated to this addon.

Installation

ember install ember-element-helper

Usage

{{#let (element this.tagName) as |Tag|}}
  <Tag class="my-tag">hello world!</Tag>
{{/let}}

You can also pass around the result of invoking this helper into any components that accepts "contextual components" as arguments:

<MyComponent @tag={{element "span"}} />
{{!-- in my-component.hbs --}}
{{#let @tag as |Tag|}}
  <Tag class="my-tag">hello world!</Tag>
{{/let}}

{{!-- ...or more directly... --}}
<@tag class="my-tag">hello world!</@tag>

Single File Components

Using the (element) helper with first class component templates:

import { element } from 'ember-element-helper';

<template>
  {{#let (element @tagName) as |Tag|}}
    <Tag class="my-tag">hello world!</Tag>
  {{/let}}
</template>

Glint Usage in Classic Mode

In order to use a typed (element) helper in classic mode, you need to import the addon's glint template registry and extend your app's registry declaration as described in the Using Addons documentation:

import '@glint/environment-ember-loose';
import type EmberElementHelperRegistry from 'ember-element-helper/template-registry';

declare module '@glint/environment-ember-loose/registry' {
  export default interface Registry extends EmberElementHelperRegistry, /* other addon registries */ {
    // local entries
  }
}

Note: Glint itself is still under active development, and as such breaking changes might occur. Therefore, Glint support by this addon is also considered experimental, and not covered by our SemVer contract!

Typing your Components

When your component accepts an element with the (element) helper, you want to give this argument a proper type. Here is how:

import type { ElementSignature } from 'ember-element-helper';

interface YourComponentSignature<T extends string> {
  Element: HTMLSectionElement;
  Args: {
    element?: ElementSignature['Return'];
  };
}

When the @element argument influences the Element of your component:

import type { ElementSignature, ElementFromTagName } from 'ember-element-helper';

interface YourComponentSignature<T extends string> {
  Element: ElementFromTagName<T>;
  Args: {
    element?: ElementSignature<T>['Return'];
  };
}

When your component already uses an element for a given condition. When the condition isn't met, a fallback element is used. The fallback can even be provided from the outside. Here is the type:

import type { ElementSignature, ElementFromTagName } from 'ember-element-helper';

interface YourComponentSignature<
  T extends string = 'section'
> {
  Element: HTMLButtonElement | HTMLAnchorElement | ElementFromTagName<T>;
  Args: {
    element?: ElementSignature<T>['Return'];
  };
}

Contributing

See the Contributing guide for details.

License

This project is licensed under the MIT License.

ember-element-helper's People

Contributors

bartocc avatar bertdeblock avatar chancancode avatar cibernox avatar dependabot[bot] avatar ember-tomster avatar gossi avatar ijlee2 avatar josemarluedke avatar knownasilya avatar mkszepp avatar mydea avatar nullvoxpopuli avatar rwjblue avatar sergeastapov avatar simonihmig avatar wagenet 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

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar

ember-element-helper's Issues

broccoli-babel-transpiler is opting out of caching

I get this warning when building our app:

broccoli-babel-transpiler is opting out of caching due to a plugin that does not provide a caching strategy: `(env) => {
  let b = env.syntax.builders;
  let locals = [];

  return {
    name: 'ember-element-helper',
    visitor: {
      BlockStatement: {
        enter(node) {
          locals.push(node.program.blockParams);
        },

        exit() {
          locals.pop();
        }
      },

      ElementNode: {
        enter(node) {
          locals.push(node.blockParams);
        },

        exit() {
          locals.pop();
        }
      },

      MustacheStatement(node) {
        if (isElementHelper(node, locals)) {
          let { path, params, hash } = transformParts(node, b);
          return b.mustache(path, params, hash, false, node.loc);
        }
      },

      SubExpression(node) {
        if (isElementHelper(node, locals)) {
          let { path, params, hash } = transformParts(node, b);
          return b.sexpr(path, params, hash, node.loc);
        }
      }
    }
  }
}`.

Expected a dynamic component definition, but received an object or function that did not have a component manager associated with it.

Presentnly getting this error:

Uncaught (in promise) Error: Expected a dynamic component definition, 
but received an object or function that did not have a component manager associated with it. 
The dynamic invocation was `<(result of a `(helper function findElement)` helper)>` 
or `{{(result of a `(helper function findElement)` helper)}}`, 
and the incorrect definition is the value at the path `(result of a `(helper function findElement)` helper)`, 
which was: HTMLDivElement
    <anonymous> runtime.js:3021

Has something gone wrong with a transform?
I'm using embroider.

❯ pnpm why ember-element-helper

dependencies:
ember-container-query 2.1.0
└── ember-element-helper 0.6.1
ember-element-helper 0.6.1
ember-headlessui 0.13.0
└── ember-element-helper 0.6.1

Happens on ember-source 4.4 and 4.5

Broken on canary?

Seems like canary ember-try is broken since May 3, haven't had a chance to investigate what's up just yet

When using in an addon the helper throws unexpected error

When I use the following code directly in application.hbs it works:

//application.hbs
{{#let (element 'h1') as |Tag|}}
  <Tag class="my-tag">Test</Tag>
{{/let}}

Scenario with error:
This component comes from an addon

//heading.hbs
{{#let (element 'h1') as |Tag|}}
  <Tag class="my-tag">{{yield}}</Tag>
{{/let}}
// application.hbs
<Heading>Test</Heading>

throws the following error:

Uncaught (in promise) Error: Assertion Failed: The `element` helper polyfill encountered an unexpected error. Please report the issue at http://github.com/tildeio/ember-element-helper with the usage and conditions that caused this error.
    Ember 3
    deprecateMutationsInTrackingTransaction validator.js:180
    Ember 2
    cache manager.js:949
    tag reference.js:161
    track validator.js:820
    valueForRef reference.js:160
    <anonymous> runtime.js:2479
    evaluate runtime.js:1284
    evaluateSyscall runtime.js:5179
    evaluateInner runtime.js:5135
    evaluateOuter runtime.js:5127
    next runtime.js:6259
    _execute runtime.js:6243
    execute runtime.js:6213
    sync runtime.js:6316
    runInTrackingTransaction validator.js:154
    sync runtime.js:6316
    Ember 3
    inTransaction runtime.js:5021
    Ember 5
    invoke backburner.js:340
    flush backburner.js:229
    flush backburner.js:426
    _end backburner.js:960
    _boundAutorunEnd backburner.js:629
    promise callback*buildNext/< backburner.js:28
    flush Ember
    _scheduleAutorun backburner.js:1179
    _end backburner.js:970
    _boundAutorunEnd backburner.js:629
    promise callback*buildNext/< backburner.js:28
    flush Ember
    _scheduleAutorun backburner.js:1179
    _end backburner.js:970
    _boundAutorunEnd backburner.js:629
    promise callback*buildNext/< backburner.js:28
    flush Ember
    _scheduleAutorun backburner.js:1179
    _ensureInstance backburner.js:1167
    schedule backburner.js:776
    <anonymous> Ember
    fulfill rsvp.js:428
    resolve$1 rsvp.js:403
    initializePromise rsvp.js:526
    Ember 2
    initializePromise rsvp.js:520
    Promise rsvp.js:1021
    Ember 5
    invokeCallback rsvp.js:493
    publish rsvp.js:476
    <anonymous> Ember
    invoke backburner.js:338
    flush backburner.js:229
    flush backburner.js:426
    _end backburner.js:960
    _boundAutorunEnd backburner.js:629
    promise callback*buildNext/< backburner.js:28
    flush Ember
    _scheduleAutorun backburner.js:1179
    _ensureInstance backburner.js:1167
index.js:172

What do I miss here?

Make it a polyfill?

Is this supposed to work as a polyfill for RFC389?

AFAICT it already follows the same semantics, right? So what's just needed to make it a "real" polyfill would be to make it a "no-op" when a (future) Ember version with direct support is detected, so is that planned?

Mainly asking to make sure it is safe to add as another dependency to an addon. 🙂

Types are incorrecly published and reference the ember-source built in preview types (which do not exist in sufficiently new enough projects)

I think everything would be fine if just these /// reference lines weren't present:

[types] ../node_modules/.pnpm/[email protected]_@[email protected]_@[email protected][email protected]/node_modules/ember-element-helper/declarations/helpers/element.d.ts:1:23 - error TS2688: Cannot find type definition file for 'ember-source/types/preview/@ember/object/core'.
[types] 
[types] 1 /// <reference types="ember-source/types/preview/@ember/object/core" />
[types]                         ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
[types] 
[types] ../node_modules/.pnpm/[email protected]_@[email protected]_@[email protected][email protected]/node_modules/ember-element-helper/declarations/helpers/element.d.ts:2:23 - error TS2688: Cannot find type definition file for 'ember-source/types/preview/@ember/object/mixin'.
[types] 
[types] 2 /// <reference types="ember-source/types/preview/@ember/object/mixin" />
[types]      

image

Not really sure why ts or glint would do this, as ember-source is marked as a peerDependency

Error on parallelize plugin

I got this error [broccoli-persistent-filter:Babel > [Babel: ember-element-helper]: Babel: ember-element-helper] was configured to throwUnlessParallelizable and was unable to parallelize a plugin while trying to build with the set. up

  'ember-cli-babel': { 
      includeExternalHelpers: true, 
      throwUnlessParallelizable: true, 
    }, 
 

TS2769 issued in Glint

Using this in an addon and as I was porting it to Typescript and using Glint, it's reporting the following error:

error TS2769: The given value does not appear to be usable as a component, modifier or helper.
  No overload matches this call.
    The last overload gave the following error.
      Argument of type 'HTMLElement' is not assignable to parameter of type '(...positional: unknown[]) => unknown'.

16                 <Tag

Are there types available for this? How do I backfill this or resolve this complaint for Glint?

Doesn't work in an engine?

I'm not sure this is the right repo to file a bug, but I think this addon is broken when used in an engine. I've got an unusual setup though, so it might be something else.

Basically when the dynamic element is invoked (it's being called from ember-basic-dropdown) I get Error: Could not find module '<my engine name>/components/-dynamic-element' imported from '(require)'.

Following the stack trace up, it looks like the engine file has the line define.alias("@ember/component", "<my engine name>/components/-dynamic-element");. When findModule runs, it tried to resolve @ember/component, but that isn't in the registry.

This is using ember and ember-cli 3.11.

Cant set attributes

I wanted to yield a span from a general component and set some classes and maybe other attributes on the span for consumers of the general component. Something like this:

{{yield
  (hash
    Foo=(element "span" class="truncate")
  )
}}

But its explicitly not allowed. How come? And could it be changed to be allowed?

Performance

Are there any performance optimisations that can be made?

Asking because, I'd like the ability to be able to chose a tag, but not at the expense of a slower component if I decide not to chose a tag.

I'm trying to avoid something like:

{{! my-component.hbs}}
{{#if @tag}}
  {{#let (element @tag) as |Tag|}}
    <Tag></Tag>
  {{/let}}
{{else}}
  <div></div>
{{/if}}

Given

{{#each this.oneThousandItems}}
  <MyComponent />
{{/each}}
{{#each this.oneThousandItems}}
  <MyComponent @tag="button" />
{{/each}}

Although the above looks fine, one has to duplicate actions and attributes etc placed on <Tag>, and <div>.

Thanks for any insight.

I'm seeing a decrease in speed from ~400ms to render to ~700ms

Element helper always render a div.

My case:

This example does not work for me, it returns an exception

{{#let (element 'span') as |Tag|}}
  <Tag class="my-tag">hello world!</Tag>
{{/let}}
'The `element` helper polyfill encountered an unexpected error. ' +
'Please report the issue at http://github.com/tildeio/ember-element-helper ' +
'with the usage and conditions that caused this error.'

myComponent.hbs (glimmer)

{{#let (component (-element 'span')) as |Tag|}}
  <Tag >I Want to be a span</Tag>
{{/let}}

result:

<div id="ember-#" ...> 
    I Want to be a span
</div>

Should be

<span id="ember-#" ....>
    I Want to be a span
</span>

ember-cli 3.25.2

`ember-element-helper` doesn't work since update to `0.8.5`

Helloo,

With only updating the dependencies, ember-element-helper is not working properly anymore. When calling it this way:

{{#let (element (or-else @as "div")) as |Element|}}
  <Element class={{this.classnames}} {{css-vars this.style}} ...attributes>
    {{yield}}
  </Element>
{{/let}}

We have this Stack Trace:
image

Directing us to this assertion:

export default helper(function () {
  // This helper (`element`, as opposed to `-element`) mostly exists to satisfy
  // things like `owner.hasRegistration('helper:element')`. The AST transform
  // replaces all usages of `(element ...)` into `(component (-element ...))`
  // so if this helper is invoked directly, something is wrong.

  assert('The `element` helper polyfill encountered an unexpected error. ' + 'Please report the issue at http://github.com/tildeio/ember-element-helper ' + 'with the usage and conditions that caused this error.');
  return null;
});

Here's the main dependencies versions:

    "@embroider/compat": "3.2.3",
    "@embroider/core": "3.3.0",
    "@embroider/router": "2.1.4",
    "@embroider/webpack": "3.2.0",
    "@ember/render-modifiers": "2.1.0",
    "@glimmer/component": "1.1.2",
    "@glimmer/tracking": "1.1.2",
    "@glint/core": "^1.2.1",
    "@glint/environment-ember-loose": "^1.2.1",
    "@glint/environment-ember-template-imports": "1.2.1",
    "@glint/template": "^1.2.1",
    "ember-auto-import": "2.6.3",
    "ember-cli-babel": "8.2.0",
    "ember-modifier": "4.1.0",
    "ember-source": "5.3.0",
    "ember-element-helper": "0.8.5",

As reference to this issue: cibernox/ember-basic-dropdown#713 ; if we use -element it works. What am I missing here? Is there a config I need to add?
For info, I use pnpm and used pnpm dedupe - doesn't change anything.

Is Embroider support on the roadmap?

We have an application that uses this helper. After getting past some other issues, we were able to build the app with Embroider. Then we turned on staticHelpers, and builds were failing until we removed references to (element ...). One was a reference to (element this.tag) and the other was (element '').

Is this known? Is Embroider support on the roadmap?

Error after upgrade from `0.6.1` to `0.8.5`

"@ember/test-helpers": "3.2.0",
    "@embroider/addon-shim": "1.8.6",
    "@embroider/compat": "2.0.2",
    "@embroider/core": "2.0.2",
    "@embroider/macros": "1.13.2",
    "@embroider/router": "2.1.4",
    "@embroider/util": "1.12.0",
    "@embroider/webpack": "2.1.1",
    .....
    "ember-cli": "5.3.0",
    "ember-cli-app-version": "^6.0.1",
    "ember-cli-babel": "^7.26.11",
ERROR in ./node_modules/.pnpm/[email protected]_@[email protected]_@[email protected]_@glint+te_cnni3bizkjkkf4pqlx3iihtj5m/node_modules/ember-animated/dist/components/animated-container.js
Module build failed (from ../../../../../../../../Users/villander/Projects/michael/mano-ui/node_modules/.pnpm/[email protected][email protected]/node_modules/thread-loader/dist/cjs.js):
Thread Loader (Worker 2)
$TMPDIR/embroider/2012c7/node_modules/.pnpm/[email protected]_@[email protected]_@[email protected]_@glint+te_cnni3bizkjkkf4pqlx3iihtj5m/node_modules/ember-animated/dist/components/animated-container.js: Missing helper: -element in node_modules/.pnpm/[email protected]_@[email protected]_@[email protected]_@glint+te_cnni3bizkjkkf4pqlx3iihtj5m/node_modules/ember-animated/dist/components/animated-container.js
    at CompatResolver.reportError (/Users/villander/Projects/michael/app-ui/node_modules/.pnpm/@[email protected]_patch_hash=xfwpwlobabhwhrnzagwhtrsove_@[email protected]/node_modules/@embroider/compat/src/resolver.js:219:21)
    at emit (/Users/villander/Projects/michael/app-ui/node_modules/.pnpm/@[email protected]_patch_hash=xfwpwlobabhwhrnzagwhtrsove_@[email protected]/node_modules/@embroider/compat/src/resolver-transform.js:27:30)
    at SubExpression (/Users/villander/Projects/michael/app-ui/node_modules/.pnpm/@[email protected]_patch_hash=xfwpwlobabhwhrnzagwhtrsove_@[email protected]/node_modules/@embroider/compat/src/resolver-transform.js:151:21)
    at visitNode ($TMPDIR/embroider/2012c7/node_modules/.pnpm/[email protected]_@[email protected]_@[email protected]_@[email protected][email protected][email protected]/node_modules/ember-source/vendor/ember/ember-template-compiler.js:9201:16)
    at visitArray ($TMPDIR/embroider/2012c7/node_modules/.pnpm/[email protected]_@[email protected]_@[email protected]_@[email protected][email protected][email protected]/node_modules/ember-source/vendor/ember/ember-template-compiler.js:9277:20)
    at visitKey ($TMPDIR/embroider/2012c7/node_modules/.pnpm/[email protected]_@[email protected]_@[email protected]_@[email protected][email protected][email protected]/node_modules/ember-source/vendor/ember/ember-template-compiler.js:9256:7)
    at visitNode ($TMPDIR/embroider/2012c7/node_modules/.pnpm/[email protected]_@[email protected]_@[email protected]_@[email protected][email protected][email protected]/node_modules/ember-source/vendor/ember/ember-template-compiler.js:9219:9)
    at visitArray ($TMPDIR/embroider/2012c7/node_modules/.pnpm/[email protected]_@[email protected]_@[email protected]_@[email protected][email protected][email protected]/node_modules/ember-source/vendor/ember/ember-template-compiler.js:9277:20)
    at visitKey ($TMPDIR/embroider/2012c7/node_modules/.pnpm/[email protected]_@[email protected]_@[email protected]_@[email protected][email protected][email protected]/node_modules/ember-source/vendor/ember/ember-template-compiler.js:9256:7)
    at visitNode ($TMPDIR/embroider/2012c7/node_modules/.pnpm/[email protected]_@[email protected]_@[email protected]_@[email protected][email protected][email protected]/node_modules/ember-source/vendor/ember/ember-template-compiler.js:9219:9)
    at visitArray ($TMPDIR/embroider/2012c7/node_modules/.pnpm/[email protected]_@[email protected]_@[email protected]_@[email protected][email protected][email protected]/node_modules/ember-source/vendor/ember/ember-template-compiler.js:9277:20)
    at visitKey ($TMPDIR/embroider/2012c7/node_modules/.pnpm/[email protected]_@[email protected]_@[email protected]_@[email protected][email protected][email protected]/node_modules/ember-source/vendor/ember/ember-template-compiler.js:9256:7)
    at visitNode ($TMPDIR/embroider/2012c7/node_modules/.pnpm/[email protected]_@[email protected]_@[email protected]_@[email protected][email protected][email protected]/node_modules/ember-source/vendor/ember/ember-template-compiler.js:9219:9)
    at visitArray ($TMPDIR/embroider/2012c7/node_modules/.pnpm/[email protected]_@[email protected]_@[email protected]_@[email protected][email protected][email protected]/node_modules/ember-source/vendor/ember/ember-template-compiler.js:9277:20)
    at visitKey ($TMPDIR/embroider/2012c7/node_modules/.pnpm/[email protected]_@[email protected]_@[email protected]_@[email protected][email protected][email protected]/node_modules/ember-source/vendor/ember/ember-template-compiler.js:9256:7)
    at visitNode ($TMPDIR/embroider/2012c7/node_modules/.pnpm/[email protected]_@[email protected]_@[email protected]_@[email protected][email protected][email protected]/node_modules/ember-source/vendor/ember/ember-template-compiler.js:9219:9)
    at visitKey ($TMPDIR/embroider/2012c7/node_modules/.pnpm/[email protected]_@[email protected]_@[email protected]_@[email protected][email protected][email protected]/node_modules/ember-source/vendor/ember/ember-template-compiler.js:9259:20)
    at visitNode ($TMPDIR/embroider/2012c7/node_modules/.pnpm/[email protected]_@[email protected]_@[email protected]_@[email protected][email protected][email protected]/node_modules/ember-source/vendor/ember/ember-template-compiler.js:9219:9)
    at visitArray ($TMPDIR/embroider/2012c7/node_modules/.pnpm/[email protected]_@[email protected]_@[email protected]_@[email protected][email protected][email protected]/node_modules/ember-source/vendor/ember/ember-template-compiler.js:9277:20)
    at visitKey ($TMPDIR/embroider/2012c7/node_modules/.pnpm/[email protected]_@[email protected]_@[email protected]_@[email protected][email protected][email protected]/node_modules/ember-source/vendor/ember/ember-template-compiler.js:9256:7)
    at visitNode ($TMPDIR/embroider/2012c7/node_modules/.pnpm/[email protected]_@[email protected]_@[email protected]_@[email protected][email protected][email protected]/node_modules/ember-source/vendor/ember/ember-template-compiler.js:9219:9)
    at traverse ($TMPDIR/embroider/2012c7/node_modules/.pnpm/[email protected]_@[email protected]_@[email protected]_@[email protected][email protected][email protected]/node_modules/ember-source/vendor/ember/ember-template-compiler.js:9314:5)
    at preprocess ($TMPDIR/embroider/2012c7/node_modules/.pnpm/[email protected]_@[email protected]_@[email protected]_@[email protected][email protected][email protected]/node_modules/ember-source/vendor/ember/ember-template-compiler.js:10640:9)
    at normalize ($TMPDIR/embroider/2012c7/node_modules/.pnpm/[email protected]_@[email protected]_@[email protected]_@[email protected][email protected][email protected]/node_modules/ember-source/vendor/ember/ember-template-compiler.js:11180:15)
    at precompileJSON ($TMPDIR/embroider/2012c7/node_modules/.pnpm/[email protected]_@[email protected]_@[email protected]_@[email protected][email protected][email protected]/node_modules/ember-source/vendor/ember/ember-template-compiler.js:4981:47)
    at precompile ($TMPDIR/embroider/2012c7/node_modules/.pnpm/[email protected]_@[email protected]_@[email protected]_@[email protected][email protected][email protected]/node_modules/ember-source/vendor/ember/ember-template-compiler.js:5014:31)
    at Object.precompile ($TMPDIR/embroider/2012c7/node_modules/.pnpm/[email protected]_@[email protected]_@[email protected]_@[email protected][email protected][email protected]/node_modules/ember-source/vendor/ember/ember-template-compiler.js:16274:37)
    at insertCompiledTemplate (/Users/villander/Projects/michael/app-ui/node_modules/.pnpm/[email protected]/node_modules/babel-plugin-ember-template-compilation/src/plugin.js:197:64)
    at PluginPass.CallExpression (/Users/villander/Projects/michael/app-ui/node_modules/.pnpm/[email protected]/node_modules/babel-plugin-ember-template-compilation/src/plugin.js:129:25)
    at PluginPass.<anonymous> (/Users/villander/Projects/michael/app-ui/node_modules/.pnpm/@[email protected]/node_modules/@embroider/core/src/portable-babel-launcher.js:37:29)
    at newFn (/Users/villander/Projects/michael/app-ui/node_modules/.pnpm/@[email protected][email protected]/node_modules/@babel/traverse/lib/visitors.js:159:14)
    at NodePath._call (/Users/villander/Projects/michael/app-ui/node_modules/.pnpm/@[email protected][email protected]/node_modules/@babel/traverse/lib/path/context.js:46:20)
    at NodePath.call (/Users/villander/Projects/michael/app-ui/node_modules/.pnpm/@[email protected][email protected]/node_modules/@babel/traverse/lib/path/context.js:36:17)
    at NodePath.visit (/Users/villander/Projects/michael/app-ui/node_modules/.pnpm/@[email protected][email protected]/node_modules/@babel/traverse/lib/path/context.js:82:31)
    at TraversalContext.visitQueue (/Users/villander/Projects/michael/app-ui/node_modules/.pnpm/@[email protected][email protected]/node_modules/@babel/traverse/lib/context.js:86:16)
    at TraversalContext.visitSingle (/Users/villander/Projects/michael/app-ui/node_modules/.pnpm/@[email protected][email protected]/node_modules/@babel/traverse/lib/context.js:65:19)
    at TraversalContext.visit (/Users/villander/Projects/michael/app-ui/node_modules/.pnpm/@[email protected][email protected]/node_modules/@babel/traverse/lib/context.js:109:19)
    at traverseNode (/Users/villander/Projects/michael/app-ui/node_modules/.pnpm/@[email protected][email protected]/node_modules/@babel/traverse/lib/traverse-node.js:22:17)
    at NodePath.visit (/Users/villander/Projects/michael/app-ui/node_modules/.pnpm/@[email protected][email protected]/node_modules/@babel/traverse/lib/path/context.js:88:52)
    at TraversalContext.visitQueue (/Users/villander/Projects/michael/app-ui/node_modules/.pnpm/@[email protected][email protected]/node_modules/@babel/traverse/lib/context.js:86:16)
    at TraversalContext.visitMultiple (/Users/villander/Projects/michael/app-ui/node_modules/.pnpm/@[email protected][email protected]/node_modules/@babel/traverse/lib/context.js:61:17)
    at TraversalContext.visit (/Users/villander/Projects/michael/app-ui/node_modules/.pnpm/@[email protected][email protected]/node_modules/@babel/traverse/lib/context.js:107:19)
    at traverseNode (/Users/villander/Projects/michael/app-ui/node_modules/.pnpm/@[email protected][email protected]/node_modules/@babel/traverse/lib/traverse-node.js:22:17)
    at NodePath.visit (/Users/villander/Projects/michael/app-ui/node_modules/.pnpm/@[email protected][email protected]/node_modules/@babel/traverse/lib/path/context.js:88:52)
    at TraversalContext.visitQueue (/Users/villander/Projects/michael/app-ui/node_modules/.pnpm/@[email protected][email protected]/node_modules/@babel/traverse/lib/context.js:86:16)
    at TraversalContext.visitMultiple (/Users/villander/Projects/michael/app-ui/node_modules/.pnpm/@[email protected][email protected]/node_modules/@babel/traverse/lib/context.js:61:17)
    at TraversalContext.visit (/Users/villander/Projects/michael/app-ui/node_modules/.pnpm/@[email protected][email protected]/node_modules/@babel/traverse/lib/context.js:107:19)
    at traverseNode (/Users/villander/Projects/michael/app-ui/node_modules/.pnpm/@[email protected][email protected]/node_modules/@babel/traverse/lib/traverse-node.js:22:17)
    at NodePath.visit (/Users/villander/Projects/michael/app-ui/node_modules/.pnpm/@[email protected][email protected]/node_modules/@babel/traverse/lib/path/context.js:88:52)
    at TraversalContext.visitQueue (/Users/villander/Projects/michael/app-ui/node_modules/.pnpm/@[email protected][email protected]/node_modules/@babel/traverse/lib/context.js:86:16)
 @ ./components/animated-container.js 1:0-74 1:0-74
 @ ./components/notes/note-board/index.hbs 5:0-60 120:64-81
 @ ./components/notes/note-board/index.ts 7:0-35 39:21-29
 @ ./tests/integration/components/notes/note-board/component-test.ts 2:0-81 35:22-36 58:22-36 91:22-36 119:22-36 159:22-36 191:24-38 215:24-38 240:24-38
 @ ./assets/test.js 191:13-90

webpack 5.88.2 compiled with 1 error in 18522 ms
Build Error (PackagerRunner) in node_modules/.pnpm/[email protected]_@[email protected]_@[email protected]_@glint+te_cnni3bizkjkkf4pqlx3iihtj5m/node_modules/ember-animated/dist/components/animated-container.js

Module build failed (from ../../../../../../../../Users/villander/Projects/michael/app-ui/node_modules/.pnpm/[email protected][email protected]/node_modules/thread-loader/dist/cjs.js):
Thread Loader (Worker 2)
$TMPDIR/embroider/2012c7/node_modules/.pnpm/[email protected]_@[email protected]_@[email protected]_@glint+te_cnni3bizkjkkf4pqlx3iihtj5m/node_modules/ember-animated/dist/components/animated-container.js/animated-container.js: Missing helper: -element in node_modules/.pnpm/[email protected]_@[email protected]_@[email protected]_@glint+te_cnni3bizkjkkf4pqlx3iihtj5m/node_modules/ember-animated/dist/components/animated-container.js

    at CompatResolver.reportError (/Users/villander/Projects/michael/app-ui/node_modules/.pnpm/@[email protected]_patch_hash=xfwpwlobabhwhrnzagwhtrsove_@[email protected]/node_modules/@embroider/compat/src/resolver.js:219:21)
    at emit (/Users/villander/Projects/michael/app-ui/node_modules/.pnpm/@[email protected]_patch_hash=xfwpwlobabhwhrnzagwhtrsove_@[email protected]/node_modules/@embroider/compat/src/resolver-transform.js:27:30)
    at SubExpression (/Users/villander/Projects/michael/app-ui/node_modules/.pnpm/@[email protected]_patch_hash=xfwpwlobabhwhrnzagwhtrsove_@[email protected]/node_modules/@embroider/compat/src/resolver-transform.js:151:21)
    at visitNode ($TMPDIR/embroider/2012c7/node_modules/.pnpm/[email protected]_@[email protected]_@[email protected]_@[email protected][email protected][email protected]/node_modules/ember-source/vendor/ember/ember-template-compiler.js:9201:16)
    at visitArray ($TMPDIR/embroider/2012c7/node_modules/.pnpm/[email protected]_@[email protected]_@[email protected]_@[email protected][email protected][email protected]/node_modules/ember-source/vendor/ember/ember-template-compiler.js:9277:20)
    at visitKey ($TMPDIR/embroider/2012c7/node_modules/.pnpm/[email protected]_@[email protected]_@[email protected]_@[email protected][email protected][email protected]/node_modules/ember-source/vendor/ember/ember-template-compiler.js:9256:7)
    at visitNode ($TMPDIR/embroider/2012c7/node_modules/.pnpm/[email protected]_@[email protected]_@[email protected]_@[email protected][email protected][email protected]/node_modules/ember-source/vendor/ember/ember-template-compiler.js:9219:9)
    at visitArray ($TMPDIR/embroider/2012c7/node_modules/.pnpm/[email protected]_@[email protected]_@[email protected]_@[email protected][email protected][email protected]/node_modules/ember-source/vendor/ember/ember-template-compiler.js:9277:20)
    at visitKey ($TMPDIR/embroider/2012c7/node_modules/.pnpm/[email protected]_@[email protected]_@[email protected]_@[email protected][email protected][email protected]/node_modules/ember-source/vendor/ember/ember-template-compiler.js:9256:7)
    at visitNode ($TMPDIR/embroider/2012c7/node_modules/.pnpm/[email protected]_@[email protected]_@[email protected]_@[email protected][email protected][email protected]/node_modules/ember-source/vendor/ember/ember-template-compiler.js:9219:9)
    at visitArray ($TMPDIR/embroider/2012c7/node_modules/.pnpm/[email protected]_@[email protected]_@[email protected]_@[email protected][email protected][email protected]/node_modules/ember-source/vendor/ember/ember-template-compiler.js:9277:20)
    at visitKey ($TMPDIR/embroider/2012c7/node_modules/.pnpm/[email protected]_@[email protected]_@[email protected]_@[email protected][email protected][email protected]/node_modules/ember-source/vendor/ember/ember-template-compiler.js:9256:7)
    at visitNode ($TMPDIR/embroider/2012c7/node_modules/.pnpm/[email protected]_@[email protected]_@[email protected]_@[email protected][email protected][email protected]/node_modules/ember-source/vendor/ember/ember-template-compiler.js:9219:9)
    at visitArray ($TMPDIR/embroider/2012c7/node_modules/.pnpm/[email protected]_@[email protected]_@[email protected]_@[email protected][email protected][email protected]/node_modules/ember-source/vendor/ember/ember-template-compiler.js:9277:20)
    at visitKey ($TMPDIR/embroider/2012c7/node_modules/.pnpm/[email protected]_@[email protected]_@[email protected]_@[email protected][email protected][email protected]/node_modules/ember-source/vendor/ember/ember-template-compiler.js:9256:7)
    at visitNode ($TMPDIR/embroider/2012c7/node_modules/.pnpm/[email protected]_@[email protected]_@[email protected]_@[email protected][email protected][email protected]/node_modules/ember-source/vendor/ember/ember-template-compiler.js:9219:9)
    at visitKey ($TMPDIR/embroider/2012c7/node_modules/.pnpm/[email protected]_@[email protected]_@[email protected]_@[email protected][email protected][email protected]/node_modules/ember-source/vendor/ember/ember-template-compiler.js:9259:20)
    at visitNode ($TMPDIR/embroider/2012c7/node_modules/.pnpm/[email protected]_@[email protected]_@[email protected]_@[email protected][email protected][email protected]/node_modules/ember-source/vendor/ember/ember-template-compiler.js:9219:9)
    at visitArray ($TMPDIR/embroider/2012c7/node_modules/.pnpm/[email protected]_@[email protected]_@[email protected]_@[email protected][email protected][email protected]/node_modules/ember-source/vendor/ember/ember-template-compiler.js:9277:20)
    at visitKey ($TMPDIR/embroider/2012c7/node_modules/.pnpm/[email protected]_@[email protected]_@[email protected]_@[email protected][email protected][email protected]/node_modules/ember-source/vendor/ember/ember-template-compiler.js:9256:7)
    at visitNode ($TMPDIR/embroider/2012c7/node_modules/.pnpm/[email protected]_@[email protected]_@[email protected]_@[email protected][email protected][email protected]/node_modules/ember-source/vendor/ember/ember-template-compiler.js:9219:9)
    at traverse ($TMPDIR/embroider/2012c7/node_modules/.pnpm/[email protected]_@[email protected]_@[email protected]_@[email protected][email protected][email protected]/node_modules/ember-source/vendor/ember/ember-template-compiler.js:9314:5)
    at preprocess ($TMPDIR/embroider/2012c7/node_modules/.pnpm/[email protected]_@[email protected]_@[email protected]_@[email protected][email protected][email protected]/node_modules/ember-source/vendor/ember/ember-template-compiler.js:10640:9)
    at normalize ($TMPDIR/embroider/2012c7/node_modules/.pnpm/[email protected]_@[email protected]_@[email protected]_@[email protected][email protected][email protected]/node_modules/ember-source/vendor/ember/ember-template-compiler.js:11180:15)
    at precompileJSON ($TMPDIR/embroider/2012c7/node_modules/.pnpm/[email protected]_@[email protected]_@[email protected]_@[email protected][email protected][email protected]/node_modules/ember-source/vendor/ember/ember-template-compiler.js:4981:47)
    at precompile ($TMPDIR/embroider/2012c7/node_modules/.pnpm/[email protected]_@[email protected]_@[email protected]_@[email protected][email protected][email protected]/node_modules/ember-source/vendor/ember/ember-template-compiler.js:5014:31)
    at Object.precompile ($TMPDIR/embroider/2012c7/node_modules/.pnpm/[email protected]_@[email protected]_@[email protected]_@[email protected][email protected][email protected]/node_modules/ember-source/vendor/ember/ember-template-compiler.js:16274:37)
    at insertCompiledTemplate (/Users/villander/Projects/michael/app-ui/node_modules/.pnpm/[email protected]/node_modules/babel-plugin-ember-template-compilation/src/plugin.js:197:64)
    at PluginPass.CallExpression (/Users/villander/Projects/michael/app-ui/node_modules/.pnpm/[email protected]/node_modules/babel-plugin-ember-template-compilation/src/plugin.js:129:25)
    at PluginPass.<anonymous> (/Users/villander/Projects/michael/app-ui/node_modules/.pnpm/@[email protected]/node_modules/@embroider/core/src/portable-babel-launcher.js:37:29)
    at newFn (/Users/villander/Projects/michael/app-ui/node_modules/.pnpm/@[email protected][email protected]/node_modules/@babel/traverse/lib/visitors.js:159:14)
    at NodePath._call (/Users/villander/Projects/michael/app-ui/node_modules/.pnpm/@[email protected][email protected]/node_modules/@babel/traverse/lib/path/context.js:46:20)
    at NodePath.call (/Users/villander/Projects/michael/app-ui/node_modules/.pnpm/@[email protected][email protected]/node_modules/@babel/traverse/lib/path/context.js:36:17)
    at NodePath.visit (/Users/villander/Projects/michael/app-ui/node_modules/.pnpm/@[email protected][email protected]/node_modules/@babel/traverse/lib/path/context.js:82:31)
    at TraversalContext.visitQueue (/Users/villander/Projects/michael/app-ui/node_modules/.pnpm/@[email protected][email protected]/node_modules/@babel/traverse/lib/context.js:86:16)
    at TraversalContext.visitSingle (/Users/villander/Projects/michael/app-ui/node_modules/.pnpm/@[email protected][email protected]/node_modules/@babel/traverse/lib/context.js:65:19)
    at TraversalContext.visit (/Users/villander/Projects/michael/app-ui/node_modules/.pnpm/@[email protected][email protected]/node_modules/@babel/traverse/lib/context.js:109:19)
    at traverseNode (/Users/villander/Projects/michael/app-ui/node_modules/.pnpm/@[email protected][email protected]/node_modules/@babel/traverse/lib/traverse-node.js:22:17)
    at NodePath.visit (/Users/villander/Projects/michael/app-ui/node_modules/.pnpm/@[email protected][email protected]/node_modules/@babel/traverse/lib/path/context.js:88:52)
    at TraversalContext.visitQueue (/Users/villander/Projects/michael/app-ui/node_modules/.pnpm/@[email protected][email protected]/node_modules/@babel/traverse/lib/context.js:86:16)
    at TraversalContext.visitMultiple (/Users/villander/Projects/michael/app-ui/node_modules/.pnpm/@[email protected][email protected]/node_modules/@babel/traverse/lib/context.js:61:17)
    at TraversalContext.visit (/Users/villander/Projects/michael/app-ui/node_modules/.pnpm/@[email protected][email protected]/node_modules/@babel/traverse/lib/context.js:107:19)
    at traverseNode (/Users/villander/Projects/michael/app-ui/node_modules/.pnpm/@[email protected][email protected]/node_modules/@babel/traverse/lib/traverse-node.js:22:17)
    at NodePath.visit (/Users/villander/Projects/michael/app-ui/node_modules/.pnpm/@[email protected][email protected]/node_modules/@babel/traverse/lib/path/context.js:88:52)
    at TraversalContext.visitQueue (/Users/villander/Projects/michael/app-ui/node_modules/.pnpm/@[email protected][email protected]/node_modules/@babel/traverse/lib/context.js:86:16)
    at TraversalContext.visitMultiple (/Users/villander/Projects/michael/app-ui/node_modules/.pnpm/@[email protected][email protected]/node_modules/@babel/traverse/lib/context.js:61:17)
    at TraversalContext.visit (/Users/villander/Projects/michael/app-ui/node_modules/.pnpm/@[email protected][email protected]/node_modules/@babel/traverse/lib/context.js:107:19)
    at traverseNode (/Users/villander/Projects/michael/app-ui/node_modules/.pnpm/@[email protected][email protected]/node_modules/@babel/traverse/lib/traverse-node.js:22:17)
    at NodePath.visit (/Users/villander/Projects/michael/app-ui/node_modules/.pnpm/@[email protected][email protected]/node_modules/@babel/traverse/lib/path/context.js:88:52)
    at TraversalContext.visitQueue (/Users/villander/Projects/michael/app-ui/node_modules/.pnpm/@[email protected][email protected]/node_modules/@babel/traverse/lib/context.js:86:16)


Stack Trace and Error Report: /var/folders/0v/jpdg1flj3qscvbvt728pgt8c0000gn/T/error.dump.1f9810e88f55a4e3fa5a36a5dce6bd1c.log

Release notes for v0.4.0 missing?

It looks like the v0.4.0 has no release notes describing what was changed in this release. v0.3.2 had such notes though which is quite helpful in knowing what the breaking changes are.

Regression: unable to parallelize plugin

As of 0.5.5 (haven't tested against earlier 0.5.x releases), this is once again throwing during build:

[broccoli-persistent-filter:Babel > [Babel: @embroider/macros]: Babel: @embroider/macros] was configured to throwUnlessParallelizable and was unable to parallelize a plugin.

Same issue as #33, but apparently now for @embroider/macros instead. May be a broader issue with @embroider/macros and not specific to this repo?

Update past embroider 0.39.x

In 0.5.0, ember-element-helper depends on 0.39.x of the @embroider/util:

https://github.com/tildeio/ember-element-helper/blob/v0.5.0/package.json#L24

This version has a dependency on broccoli-funnel that points to a github.com address:

https://github.com/embroider-build/embroider/blob/v0.39.1/packages/util/package.json#L32

Some enterprise systems don't allow accessing github.com from inside a firewall, which means that [email protected] is not installable in these environments.

Also, since this is a pre-1.0 dependency , npm treats the 0.41.0 as similar to a post-1.0 major version, so it will not automatically be installed even though ^0.40.0 is specified.

See a similar issue in cibernox/ember-basic-dropdown#616 and fix in cibernox/ember-basic-dropdown@6e9245f

Cannot pass as argument

I thought I'd be clever and pass the {{element}} as a primitive to my component, would look like this:

<MyBuilder @element={{element "aside"}}>

but got this message instead:

Error: the `element` helper cannot be appended to the DOM directly

which relates to these lines:

MustacheStatement(node) {
if (isElementHelper(node, locals)) {
throw error('cannot be appended to the DOM directly', node);
}
},

I am now wondering if my idea is a valid use-case?

Unexpected issue after upgrade ember-animated

My app uses embroider and I was trying to fix the Ember 3.28 deprecations by upgrading ember-animated to the latest version.

In my app we use it in the main route:

// application.hbs

<Navbar />

// navbar.hbs

<AnimatedContainer>
  {{! our code }}
</AnimatedContainer>

image

Can we drop the ast transform?

I don't understand why this addon uses an AST transform to rewrite element to -element.

If it's an attempt at future-compatibility with a glimmer-native implementation, that seems defeated by the fact that this addon already ships a helper named element anyway. So why not use that helper and eliminate the need for a custom transform?

The motivation for eliminating the transform is that we do not intend to let v2 addons automatically install AST transforms, so if this is kept it's going to become an extra manual step that users of the addon will need to deal with.

Uncaught Error: Assertion Failed: The `element` helper polyfill encountered an unexpected error

Hi! Please can someone help me with this error?
I can't solve it and I'm thinking it's a bug.

Error:

Uncaught Error: Assertion Failed: The `element` helper polyfill encountered an unexpected error. Please report the issue at http://github.com/tildeio/ember-element-helper with the usage and conditions that caused this error.
    at assert (index.js:181:1)
    at element.js:14:1
    at index.js:5258:1
    at deprecateMutationsInTrackingTransaction (validator.js:191:1)
    at index.js:5257:1
    at SimpleClassicHelperManager.getValue (index.js:5268:1)
    at manager.js:971:1
    at reference.js:170:1
    at track (validator.js:835:1)
    at valueForRef (reference.js:169:1)

package.json

shell>cat package.json | grep leaflet
    "ember-leaflet": "^5.0.1",
    "leaflet": "^1.8.0",

Environment:

shell>ember -v
ember-cli: 3.28.5
node: 14.15.5
os: linux x64

Printscreen:
image

bumping 1 addon's version of ember-element-helper to 0.6.1 causes downstream test failures

Hi, I bumped 1 addon's dependency on ember-element-helper from 0.5.5 to 0.6.1

I also added a resolution in the addon to "ember-element-helper": "^0.6.1".

Once the PR merged, 2 other downstream addons had many test failures:
Each Test failure had the same error:

global failure: Error: Assertion Failed: The `element` helper polyfill encountered an unexpected error. Please report the issue at http://github.com/tildeio/ember-element-helper with the usage and conditions that caused this error."Source:
Error: Assertion Failed: The `element` helper polyfill encountered an unexpected error. Please report the issue at http://github.com/tildeio/ember-element-helper with the usage and conditions that caused this error.
    at Object.assert (http://localhost:7357/assets/vendor.js:41738:15)
    at http://localhost:7357/assets/vendor.js:344134:32
    at http://localhost:7357/assets/vendor.js:14440:27
    at deprecateMutationsInTrackingTransaction (http://localhost:7357/assets/vendor.js:63413:9)
    at http://localhost:7357/assets/vendor.js:14439:66
    at SimpleClassicHelperManager.getValue (http://localhost:7357/assets/vendor.js:14450:14)
    at http://localhost:7357/assets/vendor.js:49844:70
    at http://localhost:7357/assets/vendor.js:54144:37
    at track (http://localhost:7357/assets/vendor.js:64057:7)
    at valueForRef (http://localhost:7357/assets/vendor.js:54143:44)"
    

on ember 3.26

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.