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

Not importing directories #4

Open
rmsheppard opened this issue May 7, 2018 · 1 comment
Open

Not importing directories #4

rmsheppard opened this issue May 7, 2018 · 1 comment

Comments

@rmsheppard
Copy link

rmsheppard commented May 7, 2018

Trying to import all files in a directory but it is causing my app to crash:

import LogViews from './Logs'

When looking at the error in my webpack console I see the follow exceptions:

] looking for modules in C:\myProject\node_modules
[WEBPACK] using description file: C:\myProject\package.json (relative path: ./node_modules)
[WEBPACK] Field 'browser' doesn't contain a valid alias configuration
[WEBPACK] after using description file: C:\myProject\package.json (relative path: ./node_modules)
[WEBPACK] using description file: C:\myProject\package.json (relative path: ./node_modules/Logs/ChangeHistoryLog)
[WEBPACK] no extension
[WEBPACK] Field 'browser' doesn't contain a valid alias configuration
[WEBPACK] C:\myProject\node_modules\Logs\ChangeHistoryLog doesn't exist
[WEBPACK] .json
[WEBPACK] Field 'browser' doesn't contain a valid alias configuration
[WEBPACK] C:\myProject\node_modules\Logs\ChangeHistoryLog.json doesn't exist
[WEBPACK] .js
[WEBPACK] Field 'browser' doesn't contain a valid alias configuration
[WEBPACK] C:\myProject\node_modules\Logs\ChangeHistoryLog.js doesn't exist
[WEBPACK] as directory
[WEBPACK] C:\myProject\node_modules\Logs\ChangeHistoryLog doesn't exist

So, it looks like it is referencing the correct file names but can't actually find the code, and I'm guessing it falls back to checking the node modules folder. Any ideas! Could be something I'm doing wrong maybe not sure. I have it specified in the .babelrc file

{ "presets": ["react", "es2015", "stage-0"], "plugins": ["import-directory"] }

Is there a specific way to load this when using webpack?

@rmsheppard
Copy link
Author

Upon experimenting with it a little more I found that the directory being specified is not correct.

The file I am using this plugin is:

../components/logManager/logManager.js.

The logs is located in:

../components/logManager/Logs/

The only way I could get this to work was by referencing the logs as such in the logManager class:

import logs from '../logManager/Logs';

when it should be:

import logs from './Logs';

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