Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ember-math-helpers + ember-template-imports + glint #1673

Closed
MichalBryxi opened this issue Jul 22, 2024 · 2 comments · Fixed by #1694
Closed

ember-math-helpers + ember-template-imports + glint #1673

MichalBryxi opened this issue Jul 22, 2024 · 2 comments · Fixed by #1694

Comments

@MichalBryxi
Copy link
Contributor

Hello, this might be totally my own incompetence, but while playing with reproduction for #1623 I bumped into a weird situation where I can't make the ember-math-helpers work with ember-template-imports & glint. I made minimal reproducible bugreport repo that has atomic commits describing what I did in each step.

Everything there is freshly baked, so no packages should be outdated. Attached package.json will give details, but I used:

    "ember-source": "~5.10.0",
    "ember-template-imports": "^4.1.1",
    "@glint/core": "^1.4.0",
    "ember-math-helpers": "^4.0.0",

And now while starting the server I will get:

pnpm install; pnpm start
Lockfile is up to date, resolution step is skipped
Already up to date
Done in 1.8s

> sandbox@0.0.0 start /Users/michal/ember/sandbox
> ember serve

⠼ building... [@embroider/webpack]assets by chunk 3.82 MiB (id hint: vendors)
  asset assets/chunk.d1b53deda0529d4639d1.js 3.06 MiB [emitted] [immutable] [big] (id hint: vendors)
  asset assets/chunk.a63a87ed2a5efc9c9436.js 777 KiB [emitted] [immutable] [big] (id hint: vendors)
asset assets/chunk.c456aca7eb4a516581ec.js 640 KiB [emitted] [immutable] [big] (name: assets/test.js)
asset assets/chunk.d3233aaadd262ec78a72.js 326 KiB [emitted] [immutable] [big] (name: assets/sandbox.js)
Entrypoint assets/sandbox.js [big] 3.38 MiB = assets/chunk.d1b53deda0529d4639d1.js 3.06 MiB assets/chunk.d3233aaadd262ec78a72.js 326 KiB
Entrypoint assets/test.js [big] 4.45 MiB = assets/chunk.d1b53deda0529d4639d1.js 3.06 MiB assets/chunk.a63a87ed2a5efc9c9436.js 777 KiB assets/chunk.c456aca7eb4a516581ec.js 640 KiB
runtime modules 6.77 KiB 14 modules
modules by path ../ 2.8 MiB
  modules by path ../rewritten-packages/ 1.8 MiB 234 modules
  modules by path ../../.pnpm/ 1020 KiB 58 modules
modules by path ./ 7.34 KiB
  modules by path ./assets/*.js 2.81 KiB 2 modules
  modules by path ./tests/ 1.54 KiB 2 modules
  modules by path ./*.ts 1.22 KiB 2 modules
  ./config/environment.js 549 bytes [built] [code generated]
  ./templates/application.hbs 508 bytes [built] [code generated]
  ./components/foo.ts 761 bytes [built] [code generated]
+ 100 modules

ERROR in ./components/foo.ts 1:0-41
Module not found: Error: Can't resolve 'ember-math-helpers' in '/Users/michal/ember/sandbox/node_modules/.pnpm/ember-math-helpers@4.0.0_ember-source@5.10.1_@glimmer+component@1.1.2_@babel+core@7.24.9__@gl_daoc5oikm36grpoluj5gqwldua/node_modules'
resolve 'ember-math-helpers' in '/Users/michal/ember/sandbox/node_modules/.pnpm/ember-math-helpers@4.0.0_ember-source@5.10.1_@glimmer+component@1.1.2_@babel+core@7.24.9__@gl_daoc5oikm36grpoluj5gqwldua/node_modules'
  Parsed request is a module
  using description file: /Users/michal/ember/sandbox/package.json (relative path: ./node_modules/.pnpm/ember-math-helpers@4.0.0_ember-source@5.10.1_@glimmer+component@1.1.2_@babel+core@7.24.9__@gl_daoc5oikm36grpoluj5gqwldua/node_modules)
    Field 'browser' doesn't contain a valid alias configuration
    resolve as module
      /Users/michal/ember/sandbox/node_modules/.pnpm/ember-math-helpers@4.0.0_ember-source@5.10.1_@glimmer+component@1.1.2_@babel+core@7.24.9__@gl_daoc5oikm36grpoluj5gqwldua/node_modules/node_modules doesn't exist or is not a directory
      looking for modules in /Users/michal/ember/sandbox/node_modules/.pnpm/ember-math-helpers@4.0.0_ember-source@5.10.1_@glimmer+component@1.1.2_@babel+core@7.24.9__@gl_daoc5oikm36grpoluj5gqwldua/node_modules
        single file module
          using description file: /Users/michal/ember/sandbox/package.json (relative path: ./node_modules/.pnpm/ember-math-helpers@4.0.0_ember-source@5.10.1_@glimmer+component@1.1.2_@babel+core@7.24.9__@gl_daoc5oikm36grpoluj5gqwldua/node_modules/ember-math-helpers)
            no extension
              Field 'browser' doesn't contain a valid alias configuration
              /Users/michal/ember/sandbox/node_modules/.pnpm/ember-math-helpers@4.0.0_ember-source@5.10.1_@glimmer+component@1.1.2_@babel+core@7.24.9__@gl_daoc5oikm36grpoluj5gqwldua/node_modules/ember-math-helpers is not a file
            .wasm
              Field 'browser' doesn't contain a valid alias configuration
              /Users/michal/ember/sandbox/node_modules/.pnpm/ember-math-helpers@4.0.0_ember-source@5.10.1_@glimmer+component@1.1.2_@babel+core@7.24.9__@gl_daoc5oikm36grpoluj5gqwldua/node_modules/ember-math-helpers.wasm doesn't exist
            .mjs
              Field 'browser' doesn't contain a valid alias configuration
              /Users/michal/ember/sandbox/node_modules/.pnpm/ember-math-helpers@4.0.0_ember-source@5.10.1_@glimmer+component@1.1.2_@babel+core@7.24.9__@gl_daoc5oikm36grpoluj5gqwldua/node_modules/ember-math-helpers.mjs doesn't exist
            .js
              Field 'browser' doesn't contain a valid alias configuration
              /Users/michal/ember/sandbox/node_modules/.pnpm/ember-math-helpers@4.0.0_ember-source@5.10.1_@glimmer+component@1.1.2_@babel+core@7.24.9__@gl_daoc5oikm36grpoluj5gqwldua/node_modules/ember-math-helpers.js doesn't exist
            .json
              Field 'browser' doesn't contain a valid alias configuration
              /Users/michal/ember/sandbox/node_modules/.pnpm/ember-math-helpers@4.0.0_ember-source@5.10.1_@glimmer+component@1.1.2_@babel+core@7.24.9__@gl_daoc5oikm36grpoluj5gqwldua/node_modules/ember-math-helpers.json doesn't exist
            .ts
              Field 'browser' doesn't contain a valid alias configuration
              /Users/michal/ember/sandbox/node_modules/.pnpm/ember-math-helpers@4.0.0_ember-source@5.10.1_@glimmer+component@1.1.2_@babel+core@7.24.9__@gl_daoc5oikm36grpoluj5gqwldua/node_modules/ember-math-helpers.ts doesn't exist
            .hbs
              Field 'browser' doesn't contain a valid alias configuration
              /Users/michal/ember/sandbox/node_modules/.pnpm/ember-math-helpers@4.0.0_ember-source@5.10.1_@glimmer+component@1.1.2_@babel+core@7.24.9__@gl_daoc5oikm36grpoluj5gqwldua/node_modules/ember-math-helpers.hbs doesn't exist
            .hbs.js
              Field 'browser' doesn't contain a valid alias configuration
              /Users/michal/ember/sandbox/node_modules/.pnpm/ember-math-helpers@4.0.0_ember-source@5.10.1_@glimmer+component@1.1.2_@babel+core@7.24.9__@gl_daoc5oikm36grpoluj5gqwldua/node_modules/ember-math-helpers.hbs.js doesn't exist
        existing directory /Users/michal/ember/sandbox/node_modules/.pnpm/ember-math-helpers@4.0.0_ember-source@5.10.1_@glimmer+component@1.1.2_@babel+core@7.24.9__@gl_daoc5oikm36grpoluj5gqwldua/node_modules/ember-math-helpers
          using description file: /Users/michal/ember/sandbox/node_modules/.pnpm/ember-math-helpers@4.0.0_ember-source@5.10.1_@glimmer+component@1.1.2_@babel+core@7.24.9__@gl_daoc5oikm36grpoluj5gqwldua/node_modules/ember-math-helpers/package.json (relative path: .)
            using exports field: ./dist/index.js
              using description file: /Users/michal/ember/sandbox/node_modules/.pnpm/ember-math-helpers@4.0.0_ember-source@5.10.1_@glimmer+component@1.1.2_@babel+core@7.24.9__@gl_daoc5oikm36grpoluj5gqwldua/node_modules/ember-math-helpers/package.json (relative path: ./dist/index.js)
                no extension
                  Field 'browser' doesn't contain a valid alias configuration
                  /Users/michal/ember/sandbox/node_modules/.pnpm/ember-math-helpers@4.0.0_ember-source@5.10.1_@glimmer+component@1.1.2_@babel+core@7.24.9__@gl_daoc5oikm36grpoluj5gqwldua/node_modules/ember-math-helpers/dist/index.js doesn't exist
                .wasm
                  Field 'browser' doesn't contain a valid alias configuration
                  /Users/michal/ember/sandbox/node_modules/.pnpm/ember-math-helpers@4.0.0_ember-source@5.10.1_@glimmer+component@1.1.2_@babel+core@7.24.9__@gl_daoc5oikm36grpoluj5gqwldua/node_modules/ember-math-helpers/dist/index.js.wasm doesn't exist
                .mjs
                  Field 'browser' doesn't contain a valid alias configuration
                  /Users/michal/ember/sandbox/node_modules/.pnpm/ember-math-helpers@4.0.0_ember-source@5.10.1_@glimmer+component@1.1.2_@babel+core@7.24.9__@gl_daoc5oikm36grpoluj5gqwldua/node_modules/ember-math-helpers/dist/index.js.mjs doesn't exist
                .js
                  Field 'browser' doesn't contain a valid alias configuration
                  /Users/michal/ember/sandbox/node_modules/.pnpm/ember-math-helpers@4.0.0_ember-source@5.10.1_@glimmer+component@1.1.2_@babel+core@7.24.9__@gl_daoc5oikm36grpoluj5gqwldua/node_modules/ember-math-helpers/dist/index.js.js doesn't exist
                .json
                  Field 'browser' doesn't contain a valid alias configuration
                  /Users/michal/ember/sandbox/node_modules/.pnpm/ember-math-helpers@4.0.0_ember-source@5.10.1_@glimmer+component@1.1.2_@babel+core@7.24.9__@gl_daoc5oikm36grpoluj5gqwldua/node_modules/ember-math-helpers/dist/index.js.json doesn't exist
                .ts
                  Field 'browser' doesn't contain a valid alias configuration
                  /Users/michal/ember/sandbox/node_modules/.pnpm/ember-math-helpers@4.0.0_ember-source@5.10.1_@glimmer+component@1.1.2_@babel+core@7.24.9__@gl_daoc5oikm36grpoluj5gqwldua/node_modules/ember-math-helpers/dist/index.js.ts doesn't exist
                .hbs
                  Field 'browser' doesn't contain a valid alias configuration
                  /Users/michal/ember/sandbox/node_modules/.pnpm/ember-math-helpers@4.0.0_ember-source@5.10.1_@glimmer+component@1.1.2_@babel+core@7.24.9__@gl_daoc5oikm36grpoluj5gqwldua/node_modules/ember-math-helpers/dist/index.js.hbs doesn't exist
                .hbs.js
                  Field 'browser' doesn't contain a valid alias configuration
                  /Users/michal/ember/sandbox/node_modules/.pnpm/ember-math-helpers@4.0.0_ember-source@5.10.1_@glimmer+component@1.1.2_@babel+core@7.24.9__@gl_daoc5oikm36grpoluj5gqwldua/node_modules/ember-math-helpers/dist/index.js.hbs.js doesn't exist
                as directory
                  /Users/michal/ember/sandbox/node_modules/.pnpm/ember-math-helpers@4.0.0_ember-source@5.10.1_@glimmer+component@1.1.2_@babel+core@7.24.9__@gl_daoc5oikm36grpoluj5gqwldua/node_modules/ember-math-helpers/dist/index.js doesn't exist
      looking for modules in /Users/michal/ember/sandbox/node_modules/.pnpm/node_modules
        single file module
          using description file: /Users/michal/ember/sandbox/package.json (relative path: ./node_modules/.pnpm/node_modules/ember-math-helpers)
            no extension
              Field 'browser' doesn't contain a valid alias configuration
              /Users/michal/ember/sandbox/node_modules/.pnpm/node_modules/ember-math-helpers doesn't exist
            .wasm
              Field 'browser' doesn't contain a valid alias configuration
              /Users/michal/ember/sandbox/node_modules/.pnpm/node_modules/ember-math-helpers.wasm doesn't exist
            .mjs
              Field 'browser' doesn't contain a valid alias configuration
              /Users/michal/ember/sandbox/node_modules/.pnpm/node_modules/ember-math-helpers.mjs doesn't exist
            .js
              Field 'browser' doesn't contain a valid alias configuration
              /Users/michal/ember/sandbox/node_modules/.pnpm/node_modules/ember-math-helpers.js doesn't exist
            .json
              Field 'browser' doesn't contain a valid alias configuration
              /Users/michal/ember/sandbox/node_modules/.pnpm/node_modules/ember-math-helpers.json doesn't exist
            .ts
              Field 'browser' doesn't contain a valid alias configuration
              /Users/michal/ember/sandbox/node_modules/.pnpm/node_modules/ember-math-helpers.ts doesn't exist
            .hbs
              Field 'browser' doesn't contain a valid alias configuration
              /Users/michal/ember/sandbox/node_modules/.pnpm/node_modules/ember-math-helpers.hbs doesn't exist
            .hbs.js
              Field 'browser' doesn't contain a valid alias configuration
              /Users/michal/ember/sandbox/node_modules/.pnpm/node_modules/ember-math-helpers.hbs.js doesn't exist
        /Users/michal/ember/sandbox/node_modules/.pnpm/node_modules/ember-math-helpers doesn't exist
      /Users/michal/ember/sandbox/node_modules/node_modules doesn't exist or is not a directory
      looking for modules in /Users/michal/ember/sandbox/node_modules
        single file module
          using description file: /Users/michal/ember/sandbox/package.json (relative path: ./node_modules/ember-math-helpers)
            no extension
              Field 'browser' doesn't contain a valid alias configuration
              /Users/michal/ember/sandbox/node_modules/ember-math-helpers is not a file
            .wasm
              Field 'browser' doesn't contain a valid alias configuration
              /Users/michal/ember/sandbox/node_modules/ember-math-helpers.wasm doesn't exist
            .mjs
              Field 'browser' doesn't contain a valid alias configuration
              /Users/michal/ember/sandbox/node_modules/ember-math-helpers.mjs doesn't exist
            .js
              Field 'browser' doesn't contain a valid alias configuration
              /Users/michal/ember/sandbox/node_modules/ember-math-helpers.js doesn't exist
            .json
              Field 'browser' doesn't contain a valid alias configuration
              /Users/michal/ember/sandbox/node_modules/ember-math-helpers.json doesn't exist
            .ts
              Field 'browser' doesn't contain a valid alias configuration
              /Users/michal/ember/sandbox/node_modules/ember-math-helpers.ts doesn't exist
            .hbs
              Field 'browser' doesn't contain a valid alias configuration
              /Users/michal/ember/sandbox/node_modules/ember-math-helpers.hbs doesn't exist
            .hbs.js
              Field 'browser' doesn't contain a valid alias configuration
              /Users/michal/ember/sandbox/node_modules/ember-math-helpers.hbs.js doesn't exist
        existing directory /Users/michal/ember/sandbox/node_modules/ember-math-helpers
          using description file: /Users/michal/ember/sandbox/node_modules/ember-math-helpers/package.json (relative path: .)
            using exports field: ./dist/index.js
              using description file: /Users/michal/ember/sandbox/node_modules/ember-math-helpers/package.json (relative path: ./dist/index.js)
                no extension
                  Field 'browser' doesn't contain a valid alias configuration
                  /Users/michal/ember/sandbox/node_modules/ember-math-helpers/dist/index.js doesn't exist
                .wasm
                  Field 'browser' doesn't contain a valid alias configuration
                  /Users/michal/ember/sandbox/node_modules/ember-math-helpers/dist/index.js.wasm doesn't exist
                .mjs
                  Field 'browser' doesn't contain a valid alias configuration
                  /Users/michal/ember/sandbox/node_modules/ember-math-helpers/dist/index.js.mjs doesn't exist
                .js
                  Field 'browser' doesn't contain a valid alias configuration
                  /Users/michal/ember/sandbox/node_modules/ember-math-helpers/dist/index.js.js doesn't exist
                .json
                  Field 'browser' doesn't contain a valid alias configuration
                  /Users/michal/ember/sandbox/node_modules/ember-math-helpers/dist/index.js.json doesn't exist
                .ts
                  Field 'browser' doesn't contain a valid alias configuration
                  /Users/michal/ember/sandbox/node_modules/ember-math-helpers/dist/index.js.ts doesn't exist
                .hbs
                  Field 'browser' doesn't contain a valid alias configuration
                  /Users/michal/ember/sandbox/node_modules/ember-math-helpers/dist/index.js.hbs doesn't exist
                .hbs.js
                  Field 'browser' doesn't contain a valid alias configuration
                  /Users/michal/ember/sandbox/node_modules/ember-math-helpers/dist/index.js.hbs.js doesn't exist
                as directory
                  /Users/michal/ember/sandbox/node_modules/ember-math-helpers/dist/index.js doesn't exist
      /Users/michal/ember/node_modules doesn't exist or is not a directory
      /Users/michal/node_modules doesn't exist or is not a directory
      /Users/node_modules doesn't exist or is not a directory
      /node_modules doesn't exist or is not a directory
 @ ./templates/application.hbs 2:0-52 14:30-34
 @ ./assets/sandbox.js 49:13-57

webpack 5.93.0 compiled with 1 error in 7662 ms
Build Error (PackagerRunner) in components/foo.ts

Module not found: Error: Can't resolve 'ember-math-helpers' in '/Users/michal/ember/sandbox/node_modules/.pnpm/ember-math-helpers@4.0.0_ember-source@5.10.1_@glimmer+component@1.1.2_@babel+core@7.24.9__@gl_daoc5oikm36grpoluj5gqwldua/node_modules'


Stack Trace and Error Report: /var/folders/8q/yrjx_8s115q43r8w5qd90_m00000gn/T/error.dump.e0bfbfbcbd444e1245fa458074c2cf89.log
cleaning up...

You can see it in the repro repo, but I did follow the hidden README for glint configuration so really not sure what might be the issue?

@RobbieTheWagner
Copy link
Owner

RobbieTheWagner commented Jul 25, 2024

@MichalBryxi have you researched the error more? I found this https://stackoverflow.com/questions/43037590/field-browser-doesnt-contain-a-valid-alias-configuration

I think it sounds like a webpack issue, where newer webpack makes you provide all the things like browser and it sounds like it cannot find the alias for it. Unsure if that is a problem in this addon or your app.

@MichalBryxi
Copy link
Contributor Author

MichalBryxi commented Aug 1, 2024

So following the where do I import X from article I found following:

  1. When importing via import { sum } from "ember-math-helpers/helpers/sum"; the code compiles and the sum helper is useable.
  2. import { sum } from "ember-math-helpers"; does not work for me
  3. import { sum } from "./ember-math-helpers"; does not work for me
  4. Given the global dot export: ".": { "default": "./dist/index.js" } I would expect the dist folder of the package to have index.js file, but it does not seem to be the case? (see screenshot). So if that does not exist, then we can't really import from "ember-math-helpers", because there is no code to import? Or?

Screenshot 2024-08-01 at 14 56 47

MichalBryxi added a commit to MichalBryxi/ember-math-helpers that referenced this issue Aug 1, 2024
With this change following import should work:

```
import { sum } from "ember-math-helpers";
```

Fixes: RobbieTheWagner#1673
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants