autodll-webpack-plugin icon indicating copy to clipboard operation
autodll-webpack-plugin copied to clipboard

Throw Error when `pkg` is null

Open TheLarkInn opened this issue 6 years ago • 3 comments

I was working with @gdborton to setup this plugin but realized that when the context is not set directly, that the package.json path cannot be resolved.

I wanted to suggest that if you throw, or provide some error message (even in just loggin mode) when this package.json file (for the cache), is not resolvable.

TheLarkInn avatar Nov 20 '17 23:11 TheLarkInn

Hey @TheLarkInn, I am trying to understand the problem but I am kinda new to this project so I apologise if my question seems silly. Why is it that the package.json path cannot be resolved if the context is not set directly? Because, as far as I can tell, context is defaults to process.pwd.

sudo-suhas avatar Nov 21 '17 03:11 sudo-suhas

I don't remember exactly what we were doing that hit this problem, but I'm guessing this fails for sure if you run it outside of the root directory.

On Mon, Nov 20, 2017 at 7:57 PM, Suhas Karanth [email protected] wrote:

Hey @TheLarkInn https://github.com/thelarkinn, I am trying to understand the problem but I am kinda new to this project so I apologise if my question seems silly. Why is it that the package.json path cannot be resolved if the context is not set directly? Because, as far as I can tell, context is defaults to process.pwd.

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://github.com/asfktz/autodll-webpack-plugin/issues/87#issuecomment-345909800, or mute the thread https://github.com/notifications/unsubscribe-auth/AD-pI8FhwcyAuZKXD6CYT3ctCy25Lz2Bks5s4kpEgaJpZM4QlE0g .

gdborton avatar Nov 29 '17 07:11 gdborton

Hi @TheLarkInn, Thanks for for the heads up

I'm joining to the question of @sudo-suhas

@gdborton, If I understand correctly, a case where the context cannot be resolved correctly is where you have multiple projects that share the same build, something like this?

  • scripts
    • webpack.config.js
    • package.json
  • project-a
    • index.js
    • package.json
  • project-b
    • index.js
    • package.json

A use case example will be very useful (:

I noticed that currently we only take the context from the parent config but ignore the context option from the plugin itself. https://github.com/asfktz/autodll-webpack-plugin/blob/master/src/createSettings.js#L18

It should be something like: context: settings.context || parentConfig.context

I completely agree that throwing such warning is important but unsure how to detect that the context is wrong.

asfktz avatar Dec 02 '17 22:12 asfktz