Skip to content

How to replace modules #79

Closed
Closed
@jhnns

Description

@jhnns

I'm trying to update alamid to webpack@0.9.x. Our current bundling concept is a bit of a mess, but for now I'm trying to adapt alamid to webpack@0.9.x without changing the overall concept (we'll do that in the next step).

We had a resolve-module, that tried to replace server-only module with client modules. I know that webpack has an own mechanism, but ours is a bit different. It works like this:

If a .server.js-file is found, the resolve-module tries to find a .client.js-file and then just a .js-version of the module. If none of this can be found, the loader throws an exception to warn the user that he's about to require a server-only module.

There's additionally a special algorithm for files inside the node_modules/alamid-folder that tries to the same, but with whole directories. If a server-only module inside the /server/- or /core/-directory has been required, it tries to find it in the /client/-directory.

How can I accomplish that with webpack@0.9? Maybe with lib/NormalModuleReplacementPlugin.js?

You can find our implementation in /lib/core/bundle/resolveFilename.js

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions