pluginBuilder dependencies being built #289

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

Comments

Projects
None yet
8 participants
@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?

@jrburke

This comment has been minimized.

Show comment Hide comment
@jrburke

jrburke Oct 18, 2012

Owner

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.

Owner

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

This comment has been minimized.

Show comment Hide comment
@guybedford

guybedford Oct 18, 2012

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

This comment has been minimized.

Show comment Hide comment
@jrburke

jrburke Oct 18, 2012

Owner

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

Owner

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

This comment has been minimized.

Show comment Hide comment
@guybedford

guybedford Oct 18, 2012

Yes, exactly.

Yes, exactly.

@guybedford guybedford referenced this issue in requirejs/require-cs Mar 15, 2013

Open

Cross domain #43

@guybedford

This comment has been minimized.

Show comment Hide comment
@guybedford

guybedford Apr 24, 2013

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.

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

This comment has been minimized.

Show comment Hide comment
@jrburke

jrburke May 7, 2013

Owner

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.

Owner

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

This comment has been minimized.

Show comment Hide comment
@rjgotten

rjgotten Jan 14, 2014

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.

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

This comment has been minimized.

Show comment Hide comment
@jrburke

jrburke Jan 22, 2014

Owner

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

Owner

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

This comment has been minimized.

Show comment Hide comment
@rjgotten

rjgotten Jan 23, 2014

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

@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

This comment has been minimized.

Show comment Hide comment
@leachryanb

leachryanb Feb 13, 2014

+1

+1

@jugglinmike

This comment has been minimized.

Show comment Hide comment
@jugglinmike

jugglinmike Mar 5, 2014

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: [/* ... */]
}
Contributor

jugglinmike commented Mar 5, 2014

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

This comment has been minimized.

Show comment Hide comment
@jrburke

jrburke Mar 18, 2014

Owner

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

Owner

jrburke commented Mar 18, 2014

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

@jugglinmike

This comment has been minimized.

Show comment Hide comment
@jugglinmike

jugglinmike Mar 19, 2014

Contributor

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

Contributor

jugglinmike commented Mar 19, 2014

@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

This comment has been minimized.

Show comment Hide comment
@miraclebg

miraclebg Mar 21, 2016

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

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

@jugglinmike

This comment has been minimized.

Show comment Hide comment
@jugglinmike

jugglinmike Mar 22, 2016

Contributor

@miraclebg Glad it helped!

Contributor

jugglinmike commented Mar 22, 2016

@miraclebg Glad it helped!

@chrisknoll

This comment has been minimized.

Show comment Hide comment
@chrisknoll

chrisknoll Feb 22, 2017

Can you explain how using package config solved this issue?

Can you explain how using package config solved this issue?

@zilingxingzi

This comment has been minimized.

Show comment Hide comment
@zilingxingzi

zilingxingzi Sep 8, 2017

packages: [{
    name: 'css',
    location: '../node_modules/require-css/',
    main: 'css.min'
}]

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