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

feature request: better detection of component path #4

Open
trusktr opened this issue Apr 24, 2022 · 3 comments
Open

feature request: better detection of component path #4

trusktr opened this issue Apr 24, 2022 · 3 comments

Comments

@trusktr
Copy link

trusktr commented Apr 24, 2022

Here for example is a Three.js component that imports everything from an index, importing the whole Three.js lib:

https://github.com/mrdoob/three.js/blob/f9331aa74f87b12e91f34886e0ed54b8d79b31bf/examples/jsm/controls/OrbitControls.js#L1-L9

When I try to set the loader config,

					options: {
						modules: {
							three: {
								// nothing, but need this empty object literal
							},
						},
					},

the build has an error:

Module not found: Error: Package path ./LinearMipmapLinearFilter is not exported from package /home/trusktr/src/lume+lume/node_modules/three (see exports field in /home/trusktr/src/lume+lume/node_modules/three/package.json)

Besides that Webpack is trying to obey exports field, it is also trying to import the wrong path. three/LinearMipmapLinearFilter is not the file where that thing comes from; it comes from three/src/constants.

I wonder if there's a way to make it correctly detect the path of items.

@trusktr trusktr changed the title feature request: detection of component path feature request: better detection of component path Apr 24, 2022
@trusktr
Copy link
Author

trusktr commented Apr 24, 2022

I see! this works a little better, but not quite:

					options: {
						modules: {
							three: {
								components: 'src',
							},
						},
					},

@trusktr
Copy link
Author

trusktr commented Apr 24, 2022

I took a look! I see it is using TS for the AST. Maybe instead we can tell TS to resolve the original file location of given item, to get the path that way.

@trusktr
Copy link
Author

trusktr commented Apr 24, 2022

Hmmm, check out this getSourceFile method. Maybe we can use that.

https://stackoverflow.com/questions/58653091/typescript-compiler-api-find-which-file-a-type-came-from

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