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

How to render yalc add dynamically #233

Open
parithibang opened this issue Jan 1, 2024 · 1 comment
Open

How to render yalc add dynamically #233

parithibang opened this issue Jan 1, 2024 · 1 comment

Comments

@parithibang
Copy link

parithibang commented Jan 1, 2024

I am building a package and using Yalc I am publishing it in my local. My scenario is that I want a Hot Module Replacement in the package and the consuming application should automatically detect the changes.

What I have tried is that in my custom package created a watch command in package.json

"watch": "webpack --watch",

In webpack.config.js

module.exports = (env, argv) => {
  if (argv && argv.watch) {
    const watchCommand = "yalc publish --push --replace";
    config.plugins.push(
      new WebpackShellPluginNext({
        onDoneWatch: {
          scripts: [watchCommand],
          blocking: false,
          parallel: true,
        },
      })
    );
  }
  return config;
};

Then in my application directory in package.json added a custom nodemon command

"start:nodemon": "nodemon --exec 'webpack serve --env standalone'",

Application webpack.config.js

devServer: {
      hot: true,
      watchFiles: [".yalc/**/*"],
      onBeforeSetupMiddleware: (devServer) => {
        devServer.compiler.hooks.done.tap("customCommand", () => {
            exec("yalc add my-custom-package", (err, stdout, stderr) => {
              if (stdout) console.log(stdout);
            });
        });
      }
    }

The changes are not reflected while the file is saved in the package directory. But if I stop and start the start:nodemon process it is working fine.

@wclr
Copy link
Owner

wclr commented Jan 2, 2024

Yalc is too simple to be the case for such issues -) Basically, it just copies the files from one location to another.

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

2 participants