projectcaluma / ember-caluma

Ember.js addons for Caluma
https://docs.caluma.io/ember-caluma/
GNU Lesser General Public License v3.0
18 stars 22 forks source link

Failed to setup project according to getting started guide / Could not find module `ember-engines/routes` #2361

Open janikvonrotz opened 1 year ago

janikvonrotz commented 1 year ago

Hi

I tried to familiarize myself with the calluma project and therefore tried to setup a demo instance using this guide: https://caluma.gitbook.io/caluma-docs/guides/guide

In the end I got a blank page in the browser and this error:

Uncaught Error: Could not find module `ember-engines/routes` imported from `@projectcaluma/ember-form-builder/routes`

I assume this can be resolved by using the exact Node / NPM / Ember versions.

Server

Started the docker project according to the guide.

Client

Installed the ember dependencies:

➜  ~ nvm use v18.15.0
Now using node v18.15.0 (npm v9.5.0)

➜  ~ npm install -g ember-cli

➜  ~ ember new caluma-demo
installing app
Ember CLI v4.11.0

➜  ~ cd caluma-demo
➜  caluma-demo git:(master) npm start

The server started. Next I installed the ember projectcaluma package:

➜  caluma-demo git:(master) ember install @projectcaluma/ember-form-builder @projectcaluma/ember-form

And updated the files according to the guidE:

router.js

import EmberRouter from '@ember/routing/router';
import config from 'caluma-demo/config/environment';

export default class Router extends EmberRouter {
  location = config.locationType;
  rootURL = config.rootURL;
}

Router.map(function() {
  this.mount("@projectcaluma/ember-form-builder", {
    as: "form-builder",
    path: "/form-builder"
  });
});

app.js

import Application from '@ember/application';
import Resolver from 'ember-resolver';
import loadInitializers from 'ember-load-initializers';
import config from 'caluma-demo/config/environment';

export default class App extends Application {
  modulePrefix = config.modulePrefix;
  podModulePrefix = config.podModulePrefix;
  Resolver = Resolver;

  engines = {
    "@projectcaluma/ember-form-builder": {
      dependencies: {
        services: [
          "apollo", // ember-apollo-client for graphql
          "notification", // ember-uikit for notifications
          "intl", // ember-intl for i18n
          "caluma-options", // service to configure ember-caluma
          "validator" // service for generic regex validation
        ]
      }
    }
  }

}

loadInitializers(App, config.modulePrefix);

It seems the extend instruction have change, not sure if this works.

environment.js

'use strict';

module.exports = function (environment) {
  const ENV = {
    modulePrefix: 'caluma-demo',
    environment,
    rootURL: '/',
    locationType: 'history',
    EmberENV: {
      EXTEND_PROTOTYPES: false,
      FEATURES: {
        // Here you can enable experimental features on an ember canary build
        // e.g. EMBER_NATIVE_DECORATOR_SUPPORT: true
      },
    },
    apollo: {
      apiURL: "/graphql"
    },
    APP: {
      // Here you can pass flags/options to your application instance
      // when it is created
    },
  };

  //..

ember-cli-build.js

'use strict';

const EmberApp = require('ember-cli/lib/broccoli/ember-app');

module.exports = function (defaults) {
  const app = new EmberApp(defaults, {
    "ember-uikit": {
      notification: {
        "timeout": 5000,
        "group": null,
        "pos": "top-center",
      }
    }
  });

  //..

app.scss

Does not exist anymore. It seems ember has removed scss suppport.

Last step I did:

➜  caluma-demo git:(master) ✗ npm start

And then got the error.

czosel commented 1 year ago

Hi @janikvonrotz

Thank you for the detailed bug report and sorry about the late reply! I was able to reproduce the issue. We currently have an issue with the 0.9.x release of ember-engines: https://github.com/ember-engines/ember-engines/issues/833

For me, explicitly installing an older version of ember-engines fixes the issue - can you try and see if this does the trick for you as well?

npm install ember-engines@0.8.23

We'll still have to come up with a minimal reproduction of the issue to facilitate an upstream fix for this.

czosel commented 1 year ago

Also, we've just extended the Guide with some more details on how to get SCSS styling to work. Hope this helps! :slightly_smiling_face:

janikvonrotz commented 1 year ago

@czosel Thanks I will check the provided fix asap.

czosel commented 1 year ago

@janikvonrotz Turns out the root cause for the issue with ember-engines >= 0.9 was caused by another addon we maintain, ember-uikit. If you make sure you have the latest release of ember-uikit (7.0.3), you don't need to downgrade ember-engines anymore :+1: