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

fix(imports): remove resolve.root config in webpack #140

Merged
merged 1 commit into from
Jan 3, 2016

Conversation

dvdzkwsk
Copy link
Member

…bution issues

By using resolve.root and modulesDirectories overrides with webpack, consuming packages must use webpack and must have a very specific setup in order for Stardust's imports to work correctly. By using all relative paths, Stardust is able to be consumed by any bundler/environment.

@eanplatter
Copy link
Contributor

That makes sense to me, but I'm not sure if @levithomason would have any other feedback concerning this. I believe resolve.root was added in just for convenience tho.

@dvdzkwsk
Copy link
Member Author

Developer convenience makes sense, but the package ultimately has to be able to be safely imported in other environments. I came across this while importing Stardust into another application without the required (and undocumented) configuration, and while it would be easy to add I wanted to put this out in the open.

@dvdzkwsk
Copy link
Member Author

That said, I'm OK waiting on @levithomason for this, but it's a pretty critical fix that should be considered sooner rather than later.

@eanplatter
Copy link
Contributor

Oh yeah, I just mentioned that I think convenience was the primary motivating factor, so I don't think it's a big deal to do away with. It's easy to change either way, so 🍂

@ghost
Copy link

ghost commented Dec 28, 2015

To make this work we'll need to circle through the components in the docs directory as well.

@levithomason
Copy link
Member

-1 to sweeping removal of root require. The test and docs are never required by consumers. Managing those paths is rather a pain without it. Example, Sidebar.js doc site component:

import META from 'src/utils/Meta';
// vs
import META from '../../../../src/utils/Meta';

^ That is a loss of readability and maintainability with no gain.

Short term
This PR does hit the right issue, the imports in src should use relative requires. This makes more sense in most cases in the src directory anyhow since most imports are from somewhere else in src directory. It also solves the original problem.

Long term
We should have a dist build.


EDIT
Let's update this PR to only change to the src dir imports.

@levithomason
Copy link
Member

Side note, PR titles end up in the CHANGELOG. Let's write them in consideration of others reading them as changelog bullets.

@dvdzkwsk
Copy link
Member Author

Agreed about the inconvenience in test and docs, but it's definitely a necessity for the source code. Personally I don't see how this package could be reasonably compiled to a distribution bundle due to its dependencies on lodash/jquery/semantic/etc., so it's vital that the source code be easy to import.

Sent from my iPhone

On Dec 29, 2015, at 11:10 PM, Levi Thomason notifications@github.com wrote:

-1 to sweeping removal of root require. The test and docs are never required by consumers. Managing those paths is rather a pain without it. Example, Sidebar.js doc site component:

import META from 'src/utils/Meta';
// vs
import META from '../../../../src/utils/Meta';
^ That is a loss of readability and maintainability with no gain.

Short term
This PR does hit the right issue, the imports in src should use relative requires. This makes more sense in most cases in the src directory anyhow since most imports are from somewhere else in src directory. It also solves the original problem.

Long term
We should have a dist build.


Reply to this email directly or view it on GitHub.

@dvdzkwsk
Copy link
Member Author

Also as a side note, the only reason I removed the aliases from the test bundle is that I wanted to ensure that the source code worked without relying on webpack's custom resolve utilities.

Sent from my iPhone

On Dec 29, 2015, at 11:10 PM, Levi Thomason notifications@github.com wrote:

-1 to sweeping removal of root require. The test and docs are never required by consumers. Managing those paths is rather a pain without it. Example, Sidebar.js doc site component:

import META from 'src/utils/Meta';
// vs
import META from '../../../../src/utils/Meta';
^ That is a loss of readability and maintainability with no gain.

Short term
This PR does hit the right issue, the imports in src should use relative requires. This makes more sense in most cases in the src directory anyhow since most imports are from somewhere else in src directory. It also solves the original problem.

Long term
We should have a dist build.


Reply to this email directly or view it on GitHub.

@levithomason
Copy link
Member

Cool, we should merge this as soon as possible. It's borked ATM.

EDIT
Merging :)

levithomason added a commit that referenced this pull request Jan 3, 2016
fix(imports): remove resolve.root config in webpack to prevent distri…
@levithomason levithomason merged commit 82b11f6 into master Jan 3, 2016
@levithomason levithomason deleted the fix/import-paths branch January 3, 2016 23:58
@levithomason levithomason changed the title fix(imports): remove resolve.root config in webpack to prevent distri… fix(imports): remove resolve.root config in webpack Jan 4, 2016
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

Successfully merging this pull request may close these issues.

3 participants