beemojs / beemo

🤖 Centralized configuration layer for dev tools. Beep boop.
https://beemo.dev
MIT License
143 stars 9 forks source link

Driver webpack incorrect behavior #153

Closed rajzik closed 2 years ago

rajzik commented 2 years ago

Due to resolution of the beemo. Typescript file is selected when running create-config for webpack. instead of js file. Can this be fixed as webpack doesn't have native support for webpack configs?

milesj commented 2 years ago

@rajzik TS always takes precedence. I'd suggest not publishing the TS files if you only want JS to be used.

rajzik commented 2 years ago

@milesj I am using packemon and it generates files field in package.json and I didn't find how to disable it.

milesj commented 2 years ago

@rajzik Ah yeah, you can't.

I think it makes sense to only use the JS files when the strategy is copy.

rajzik commented 2 years ago

@milesj I have found workaround that is working but it's bad.

you can add prepack script that removes src from files.

Also, I found another issue with webpack, webpack config still doesn't have access to the beemo.tool or lumos.tool in my case.

Is there any working example how to setup webpack config?

rajzik commented 2 years ago

@milesj I found workaround for webpack, I need some setting from .config/lumos.ts.

configs/webpack.ts


let lumosSettings: Partial<LumosSettings> | undefined;
// eslint-disable-next-line @typescript-eslint/no-unnecessary-condition
if (!tool) {
  let path = join(process.cwd(), '.config/lumos.ts');
  if (!fs.existsSync(path)) {
    path = join(process.cwd(), '.config/lumos.js');
  }

  lumosSettings = requireModule<BeemoConfig<Partial<LumosSettings>>>(path).default.settings;
}

const settings = getSettings(tool, lumosSettings);

const {
  srcFolder,
  react,
  entryPoint,
  publicPath,
  root,
  buildFolder,
  devServerContentBase,
  moduleFederationConfig,
  host,
  enableSharedModules,
  sharedModulesManifestPath,
} = settings;

const config = getConfig({
  analyzeBundle: !!process.env.WEBPACK_ANALYZE,
  parallel: process.env.WEBPACK_PARALLEL,
  port: process.env.PORT,
  react,
  sourceMaps: !!process.env.SOURCE_MAPS,
  buildFolder: process.env.LUMOS_BUILD_FOLDER || buildFolder,
  srcFolder,
  entryPoint: process.env.LUMOS_ENTRY_POINT || entryPoint,
  publicPath,
  root,
  devServerContentBase,
  host,
  moduleFederationConfig: moduleFederationConfig as NonNullable<
    Parameters<typeof getConfig>[0]['moduleFederationConfig']
  >,
  enableSharedModules,
  sharedModulesManifestPath,
});

export default config;
milesj commented 2 years ago

@rajzik Are you talking about process.beemo.tool? Because the process stuff is only available when a config is generated, not copied/referenced.

rajzik commented 2 years ago

@milesj I see, in previous version it was possible to get setting in multiple ways. I will implement it like shown and if it is intended to have only settings for generated config then I can do it on my own. thanks.

milesj commented 2 years ago

@rajzik It's only available for generated config, not because I haven't built it for others, but because it's impossible to support or others.

When their config is loaded, it's loaded by their own tool (webpack, jest, etc), which is a separate process, so I'm unable to inject beemo into it.

That being said, I can fix the copy/ref issue this week.

rajzik commented 2 years ago

@milesj I was trying to run lumos webpack serve and there was missing beemo tool after it got to webpack-cli.

And it would be great if you fix the issue ref config. Thank you.

milesj commented 2 years ago

@rajzik Released a new patch that will only use js files for copy/ref. Let me know if that works.

rajzik commented 2 years ago

Issue is resolved. Closing. Thanks @milesj