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

ReferenceError when using preact.config.js #343

Closed
acoll opened this issue Aug 25, 2017 · 5 comments
Closed

ReferenceError when using preact.config.js #343

acoll opened this issue Aug 25, 2017 · 5 comments

Comments

@acoll
Copy link

acoll commented Aug 25, 2017

Do you want to request a feature or report a bug?
Bug

What is the current behavior?
I added a preact.config.js because I wanted to add a webpack loader. I added an empty function that does nothing. Next I ran preact watch which results in this error:

ReferenceError: [BABEL] MY_LOCAL_PATH_TO_PROJECT/preact.config.js: Unknown option: base.plugin. Check out http://babeljs.io/docs/usage/options/ for more information about options.

A common cause of this error is the presence of a configuration options object without the corresponding preset name. Example:

Invalid:
  `{ presets: [{option: value}] }`
Valid:
  `{ presets: [['presetName', {option: value}]] }`

For more detailed information on preset configuration, please see http://babeljs.io/docs/plugins/#pluginpresets-options.

I traced the bug back to here: https://github.com/developit/preact-cli/blob/master/src/lib/webpack/transform-config.js#L19.

I was able to workaround this by just creating an empty .babelrc in my project like this:

{}
@acoll acoll changed the title Error when using preact.config.js ReferenceError when using preact.config.js Aug 25, 2017
@rodush
Copy link

rodush commented Aug 28, 2017

@acoll You shouldn't do anything specific as webpack + babel work out of the box. You only add that preact.config.js file if you want to customize some webpack configuration.

@reznord
Copy link
Member

reznord commented Aug 28, 2017

creating an empty .babelrc in my project

when you do this, you are telling the preact-cli to overwrite the whole internal babel-config with what's given by the user.

@acoll
Copy link
Author

acoll commented Aug 28, 2017

@rodush Yea my intent was to add a new webpack loader that isn't included in the default webpack config (the polymer loader to be specific).

@reznord I think this makes sense, maybe the docs should mention that if you use a preact.config.js then you also need to include a babel config. Also if you don't the cli could fail with a more helpful message. If thats the right direction I'd be happy add some error handling and send a pull request.

@reznord
Copy link
Member

reznord commented Aug 28, 2017

You are wrong! You don't need to specify the .bablerc file every time you want to use preact.config.js.

It would be great if you can link to your code where you are getting this problem (the whole project) so I can test it locally.

@acoll
Copy link
Author

acoll commented Aug 28, 2017

Oh I misunderstood. Also I was unable to get the same error when starting a fresh project which led me to realize that this only happens inside a nested directory of another project with a package.json that has its own babel config.

I created a subdirectory inside an existing project and did a fresh preact create and added a preact.config.js and saw this issue. It seems like its going up a few directories to that package.json and getting an error on that babel config.

It seems like this was just caused by my weird directory structure and can be closed.

Thanks for the help. Apologies.

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

3 participants