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

Force certain webpack loaders to resolve by aliased namespace/package #4

Merged
merged 2 commits into from
Jul 23, 2018

Conversation

metatoaster
Copy link
Member

Given the lack of the concept of namespaces or modules from within the environment, typical webpack loaders will implicitly append a ./, such that the resolution of 'namespace/module' is turned into './namespace/module' (which leads to the wrong location as the build directory is almost never the current directory), unless a ~ is prepended (i.e. '~namespace/module') to force the lookup. So to ensure that the calmjs system works as expected, also supply the ./ prefixed to the alias mapping as part of the standard BaseWebpackLoaderHandler class. For webpack loaders that fully respect the resolve.alias mapping, it will enforce the correct behavior (tested with style-loader and sass-loader).

Reference:

- This forces webpack to treat any resources resolved by loaderplugins
  through the standard modname also be available through a relative `./`
  prefixed path, as certain loaders implicitly make that lookup if the
  resource is included without any prefix.
- This is in response to avoiding integrators of `calmjs.webpack` being
  forced to prefix their imports done within their non-JavaScript
  sources with webpack specific tokens which may be completely
  incompatible with standard systems (e.g. libsass).
@metatoaster metatoaster merged commit bedc502 into calmjs:master Jul 23, 2018
@metatoaster metatoaster added this to the 1.1.0 milestone Jul 25, 2018
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.

1 participant