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

"yarn watch" throws error message with lazy-controller-loader #1219

Open
Linuxmaker opened this issue Aug 20, 2023 · 2 comments
Open

"yarn watch" throws error message with lazy-controller-loader #1219

Linuxmaker opened this issue Aug 20, 2023 · 2 comments

Comments

@Linuxmaker
Copy link

Linuxmaker commented Aug 20, 2023

If I in my freshly installed project

yarn watch

run, then I get this error message here

$ encore dev --watch
Running webpack ...

ERROR Failed to compile with 1 errors 17:34:14

Module build failed: Module not found:
"./node_modules/@symfony/stimulus-bridge/If I in my freshly installed project

yarn watch

run, then I get this error message here

$ encore dev --watch
Running webpack ...

 ERROR  Failed to compile with 1 errors                                                                                                               17:34:14

Module build failed: Module not found:
"./node_modules/@symfony/stimulus-bridge/lazy-controller-loader.js!./assets/controllers/submit-confirm_controller.js" contains a reference to the file "stimulus".
This file can not be found, please check it for typos or update it if the file got moved.

Entrypoint app [big] 1.8 MiB = runtime.js 14.6 KiB vendors-node_modules_symfony_stimulus-bridge_dist_index_js-node_modules_core-js_modules_es_ar-7e6eba.css 1.1 MiB vendors-node_modules_symfony_stimulus-bridge_dist_index_js-node_modules_core-js_modules_es_ar-7e6eba.js 654 KiB app.css 773 bytes app.js 52.9 KiB
webpack compiled with 1 error

I find the content of
cat node_modules/@symfony/stimulus-bridge/lazy-controller-loader.js 
/*
 * This file is part of the Symfony package.
 *
 * (c) Fabien Potencier <fabien@symfony.com>
 *
 * For the full copyright and license information, please view the LICENSE
 * file that was distributed with this source code.
 */

'use strict';

module.exports = require('./dist/webpack/lazy-controller-loader');

Then I look at the directory contents

ls -l node_modules/@symfony/stimulus-bridge/dist/webpack/
insgesamt 228
-rw-r--r-- 1 andreas andreas    120  8. Aug 16:52 create-controllers-module.d.ts
-rw-r--r-- 1 andreas andreas    106  8. Aug 16:52 generate-lazy-controller.d.ts
-rw-r--r-- 1 andreas andreas     66  8. Aug 16:52 lazy-controller-loader.d.ts
-rw-r--r-- 1 andreas andreas 208195  8. Aug 16:52 lazy-controller-loader.js
-rw-r--r-- 1 andreas andreas     50  8. Aug 16:52 loader.d.ts
-rw-r--r-- 1 andreas andreas   5376  8. Aug 16:52 loader.js

Anyway, I don't understand why lazy-controller-loader.js causes problems. There is a reference to the "stimulus" file that cannot be found. But the following command says something else:

yarn info stimulus
yarn info v1.22.19
{
  name: 'stimulus',
  description: 'Stimulus JavaScript framework',
  'dist-tags': {
    latest: '3.2.2'
  },
  versions: [
    '0.3.0',
    '0.3.1',
...
  publishConfig: {
    access: 'public'
  },
  gitHead: '8cbca6db3b1b2ddb384deb3dd98397d3609d25a0',
  dist: {
    integrity: 'sha512-sEGK0ofeMuW+B2oPLTigCqxl47P9vRfZxeqzY5Hk1u0QPWS8DZhW+VOEEyngtzdHM+MutXKGBT8BkUKoA0060Q==',
    shasum: 'a2e955f43e12e2e5784b175d4df5517ef678aa68',
    tarball: 'https://registry.npmjs.org/stimulus/-/stimulus-3.2.2.tgz',
    fileCount: 8,
    unpackedSize: 193072,
    signatures: [
      {
        keyid: 'SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA',
        sig: 'MEQCIGZBoyOiBZ2fUGCy7GA9tFC5S24OhOrcXjgtA7KeDXRMAiB7ldWkM3Lhwq629f+LOmfZqN8lcntjtX3XBY0n1S5k+w=='
      }
    ]
  },
  directories: {}
}
Done in 0.81s.

Obviously the file "stimulus" exists. But what about this error message? Can I do 
export const app = startStimulusApp(require.context(
    '@symfony/stimulus-bridge/lazy-controller-loader!./controllers',
    true,
    /\.[jt]sx?$/
));
without? Because without this entry in "bootstrap.js" the error message does not occur.

Best regards

Andreas
@Linuxmaker
Copy link
Author

Linuxmaker commented Aug 20, 2023

It seems the file submit-confirm_controller.js is the reason for the error.

import { Controller } from 'stimulus';
export default class extends Controller {
 connect() {
 console.log('🦖');
 }
}

I'm trying to replicate this modal:
[(https://symfonycasts.com/screencast/stimulus/delete-confirm)]
Here the controller of 'stimulus' should be imported. That doesn't seem to be the case for me. Which one should I install then?

@Linuxmaker
Copy link
Author

Linuxmaker commented Aug 20, 2023

The solution seems to be adding "@hotwired":
import { Controller } from '**@hotwired/**stimulus';

Best regards
Andreas

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

No branches or pull requests

1 participant