Skip to content

pluginBuilder dependencies being built #289

Open

Description

@guybedford

I'm still stuck with these same issues affecting require-less as a plugin that builds on top of require-css. It has a pluginBuilder, which requires the require-css pluginBuilder. This results in that pluginBuilder being built in.

Perhaps pluginBuilder loads can happen in a fresh / hidden context for the builds to avoid this?

Activity

  1. jrburke commented on Oct 18, 2012

    @jrburke
    Member

    Is this the same as #228? If so, then I would prefer to just keep the conversation in that ticket since it has more history. Not saying it will get solved, but we can reopen to consider more. If you want to take a look at a patch, that would probably help move it forward.

  2. guybedford commented on Oct 18, 2012

    @guybedford
    Author

    @jrburke thanks for the quick response. It is actually different to #228.

    #228 was caused by using a pluginBuilder as a dependency as well, causing the pluginBuilder to fail. It could still be worth including a doc note about this with pluginBuilders.

    The issue here is pluginBuilder dependencies being detected as module dependencies that need writing.

    It's not a major issue as an excludeShallow fixes it, but it is important to get right at some point.

    Great, I will dive in when I have the time, but I'm not massively prioritising it for the moment though.

  3. jrburke commented on Oct 18, 2012

    @jrburke
    Member

    OK, so the issue is the pluginModule has a dependency on module 'a', but the regular plugin does not depend on 'a', and nothing else in the build depends on 'a', but 'a' ends up in the build output. Workaround is to use an excludeShallow for 'a'.

  4. guybedford commented on Oct 18, 2012

    @guybedford
    Author

    Yes, exactly.

  5. guybedford commented on Apr 24, 2013

    @guybedford
    Author

    I just wanted to bump this - it's a long standing issue on Require LESS (https://github.com/guybedford/require-less#builds), and affects all plugins made with the amd-loader builder.

    Is there a path to a fix? Any clues would be appreciated for a pull request.

  6. jrburke commented on May 7, 2013

    @jrburke
    Member

    This one is a bit tricky, as it would require keeping a separate dependency tree for the plugin, and for the builder, and attaching the plugin's dependency tree to the build output, while keeping the pluginBuilder separate.

    Perhaps the pluginBuilder could be loaded in a separate context. It may take some work though, as we need to perserve the config used from the main build context. The work would be done in build/jslib/requirePatch.js.

  7. rjgotten commented on Jan 14, 2014

    @rjgotten

    Perhaps the pluginBuilder could be loaded in a separate context. It may take some work though, as we need to perserve the config used from the main build context. The work would be done in build/jslib/requirePatch.js.

    This is exactly what I'd need for a plugin builder that has to pre-compile a client-side template language to JS functions as well. Currently I'm stuck with a manually cobbled together solution that hacks into some of the require and r.js internals to get it done, but it's ugly (and somewhat brittle).

    Really would appreciate a decent official solution.

  8. jrburke commented on Jan 22, 2014

    @jrburke
    Member

    @rjgotten if you are using a pluginBuilder, then it should be enough to then just do an exclude: [] for any of the pluginBuilder dependencies that end up in the layer, hacking internals should not be required. While it would be nice to avoid that exclusion pattern, that is the best pathway with the existing code.

  9. rjgotten commented on Jan 23, 2014

    @rjgotten

    @jrburke
    You'd think so, yes. But what if the regular build requires some of the same dependencies, only mapped to different physical files? That's exactly the kind of scenario I ended up with and it didn't quite work the way it should.

  10. leachryanb commented on Feb 13, 2014

    @leachryanb

    +1

  11. jugglinmike commented on Mar 5, 2014

    @jugglinmike
    Contributor

    I have a different problem, but it sounds like using a separate context for the pluginBuilder might resolve it as well. It looks like relative URLs are being resolved in relation to the build's baseUrl instead of the plugin's directory.

    In my case, I'm trying to use require-css, which defines pluginBuilder as './css-builder'. My workaround is to define paths for the necessary modules, but this is completely dependent on unstable details in the plugin's implementation. My r.js configuration looks something like this:

    {
      baseUrl: 'client',
      appDir: 'src',
      paths: {
        jquery: '../../bower_components/jquery/dist/jquery',
    
        // AMD loader plugins
        jade: '../../bower_components/require-jade/jade',
        css: '../../bower_components/require-css/css',
        // Temporary fix to ensure that the CSS plugins internal modules are
        // loaded correctly.
        'css-builder': '../../bower_components/require-css/css-builder',
        normalize: '../../bower_components/require-css/normalize',
      },
      mainConfigFile: 'src/client/scripts/amd-config.js',
      dir: 'out',
      optimize: 'none',
      pragmasOnSave: {
        excludeJade: true
      },
      modules: [/* ... */]
    }
  12. jrburke commented on Mar 18, 2014

    @jrburke
    Member

    @jugglinmike for that case it sounds like using package config for require-css may work better.

  13. jugglinmike commented on Mar 19, 2014

    @jugglinmike
    Contributor

    @jrburke That did the trick. Now I understand the behavior of the package config--thanks!

  14. modified the milestones: 2.2.0, 3.0 on Mar 15, 2016
  15. miraclebg commented on Mar 21, 2016

    @miraclebg

    @jugglinmike Life-and-last-lost-hour saver!

  16. jugglinmike commented on Mar 22, 2016

    @jugglinmike
    Contributor

    @miraclebg Glad it helped!

  17. chrisknoll commented on Feb 22, 2017

    @chrisknoll

    Can you explain how using package config solved this issue?

  18. zilingxingzi commented on Sep 8, 2017

    @zilingxingzi
    packages: [{
        name: 'css',
        location: '../node_modules/require-css/',
        main: 'css.min'
    }]
    
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

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