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

Add support for filename [name] tags in module names. #7

Closed
wants to merge 1 commit into from

Conversation

simonkorz
Copy link

If a file is called file.js one could use 'exports-loader?[name]' to add 'module.exports = file;' to the file.

Example usage in config:

# webpack.conf.js
module: {
    rules: [
        {
            test: /\.js$/,
            use: [
                "imports-loader?THREE=three",
                "exports-loader?THREE.[name]"
            ],
            include: helpers.root("") + "/node_modules/three/examples/js"
        }
}

This allows to use all three examples as es6 or typescript modules.

import * as THREE from "three";
import "three/examples/js/loaders/ColladaLoader";
import "three/examples/js/controls/OrbitControls";

let loader = new THREE.ColladaLoader;
let orbit = new THREE.OrbitControls;

…lled file.js one could use 'exports-loader?[name]' to add 'module.exports = file;' to the file.
@jsf-clabot
Copy link

jsf-clabot commented Jan 7, 2017

CLA assistant check
Thank you for your submission, we really appreciate it. Like many open source projects, we ask that you sign our Contributor License Agreement before we can accept your contribution.

@michael-ciniawsky
Copy link
Member

@phimonk can you please close and reopen the PR to trigger the CLA Bot again, should be working now :)

Copy link

@bebraw bebraw left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It would be better with tests, but that would be a bigger change (the project doesn't have a test setup).

We could wait till test setup is in place and look into merging after that.

@simonkorz simonkorz closed this Mar 31, 2017
@simonkorz simonkorz reopened this Mar 31, 2017
Copy link
Member

@joshwiens joshwiens left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Given the simplicity of this particular loader, i'm going to put webpack-defaults in place now. That will solve the testing infrastructure issue.

Copy link
Member

@joshwiens joshwiens left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is also going to require an addition to the readme for the additional functionality / usecase

@michael-ciniawsky
Copy link
Member

Closing in favor of #21 due to better documentation

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants