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

pluginBuilder dependencies being built #289

Open
guybedford opened this issue Oct 16, 2012 · 17 comments
Open

pluginBuilder dependencies being built #289

guybedford opened this issue Oct 16, 2012 · 17 comments
Milestone

Comments

@guybedford
Copy link

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?

@jrburke
Copy link
Member

jrburke commented Oct 18, 2012

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.

@guybedford
Copy link
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.

@jrburke
Copy link
Member

jrburke commented Oct 18, 2012

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'.

@guybedford
Copy link
Author

Yes, exactly.

@guybedford
Copy link
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.

@jrburke
Copy link
Member

jrburke commented May 7, 2013

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.

@rjgotten
Copy link

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.

@jrburke
Copy link
Member

jrburke commented Jan 22, 2014

@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.

@rjgotten
Copy link

@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.

@leachryanb
Copy link

+1

@jugglinmike
Copy link
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: [/* ... */]
}

@jrburke
Copy link
Member

jrburke commented Mar 18, 2014

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

@jugglinmike
Copy link
Contributor

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

@jrburke jrburke modified the milestones: 2.2.0, 3.0 Mar 15, 2016
@miraclebg
Copy link

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

@jugglinmike
Copy link
Contributor

@miraclebg Glad it helped!

@chrisknoll
Copy link

Can you explain how using package config solved this issue?

@zilingxingzi
Copy link

zilingxingzi commented Sep 8, 2017

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
Labels
None yet
Projects
None yet
Development

No branches or pull requests

8 participants