Skip to content

pluginBuilder doesn't carry through for wrapped plugins #209

@guybedford

Description

@guybedford

I have a requirejs plugin in the following folder structure -

js
-plugin
--plugin.js
--plugin.server.js

plugin.server.js is the pluginBuilder property in plugin.js.

I'm using a relative path to specify the pluginBuilder that looks like:

pluginBuilder: './plugin.server'

To allow for using the simpler syntax, 'plugin!...' in the project, I have a wrapper module in the base js folder of exactly the same name to allow the relative path to remap properly.

When I do a build, the pluginBuilder is not picked up, and instead the load function is taken from the plugin.js file instead of plugin.server.js file.

Should this work? Or am I doing this the wrong way?

The current fix I have for this is simply to define the pluginBuilder to be a global path of the form:

pluginBuilder: 'plugin/plugin.server'

I can then use a path mapping of the form:

paths: {
  plugin: 'plugin/plugin'
}

without having the breaking of relative paths.

I'd again appreciate advice re the best practice here.

My current feeling is that:
-global paths are preferable to relative paths
-with the above, a paths config is preferable to a wrapper module
-wrapper modules are mainly there as common-js module shims, which may be based on relative paths

My natural tendancy has been to want to think in terms of relative paths. Counter-intuitively it does seem that when performing rewrites, path mappings work far better with global paths than relative paths.

If there was some warning about relative paths somewhere in the docs, it would probably save much frustration all round.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions