akanix42 / meteor-css-modules

MIT License
92 stars 20 forks source link

Attempting to combine different files error with Meteor 1.3.2.4 #24

Closed TimBroddin closed 8 years ago

TimBroddin commented 8 years ago

I'm getting this error after updating to Meteor 1.3.2.4 with the latest version of meteor-css-modules. I'm debugging this as we speak, so I hope to share the solution with you soon.

=> Started proxy.                             
=> Started MongoDB.                           

/Users/timbroddin/.meteor/packages/less/.2.6.0.h53n1v++os+web.browser+web.cordova/plugin.compileLessBatch.os/npm/node_modules/meteor/promise/node_modules/meteor-promise/promise_server.js:116
      throw error;
            ^
Error: Attempting to combine different files:
{ type: 'js',
  sourcePath: 'app/style/style.scss',
  servePath: 'app/style/style.scss',
  installPath: 'app/style/style.scss',
  deps: { './style.css': {} },
  lazy: true,
  data: <Buffer 6d 6f 64 75 6c 65 2e 65 78 70 6f 72 74 73 20 3d 20 72 65 71 75 69 72 65 28 22 2e 2f 73 74 79 6c 65 2e 63 73 73 22 29 3b 0a>,
  hash: '39511a6d70e7980cb52ca5519c549245aa450762' }
{ type: 'js',
  data: <Buffer 65 78 70 6f 72 74 73 2e 5f 5f 65 73 4d 6f 64 75 6c 65 20 3d 20 74 72 75 65 3b 0a 0a 0a 76 61 72 20 73 74 79 6c 65 73 20 3d 20 7b 20 22 6f 75 74 65 72 43 ...>,
  sourcePath: 'app/style/style.scss',
  targetPath: 'app/style/style.scss',
  servePath: '/app/style/style.scss',
  hash: '77e7234e10a2a22276b0fcd12ef09d4c4e98601a',
  sourceMap: undefined,
  lazy: false,
  bare: false,
  mainModule: false,
  imported: true,
  installPath: 'app/style/style.scss' }

    at checkProperty (/tools/isobuild/import-scanner.js:274:15)
    at ImportScanner._combineFiles (/tools/isobuild/import-scanner.js:263:35)
    at /tools/isobuild/import-scanner.js:187:14
    at Array.forEach (native)
    at ImportScanner.addInputFiles (/tools/isobuild/import-scanner.js:158:11)
    at /tools/isobuild/compiler-plugin.js:834:15
    at Array.forEach (native)
    at Function.computeJsOutputFilesMap (/tools/isobuild/compiler-plugin.js:805:19)
    at ClientTarget._emitResources (/tools/isobuild/bundler.js:913:8)
    at /tools/isobuild/bundler.js:684:12
    at /tools/utils/buildmessage.js:359:18
    at [object Object].withValue (/tools/utils/fiber-helpers.js:89:14)
    at /tools/utils/buildmessage.js:352:34
    at [object Object].withValue (/tools/utils/fiber-helpers.js:89:14)
    at /tools/utils/buildmessage.js:350:23
    at [object Object].withValue (/tools/utils/fiber-helpers.js:89:14)
    at Object.enterJob (/tools/utils/buildmessage.js:324:26)
    at ClientTarget.make (/tools/isobuild/bundler.js:675:18)
    at /tools/isobuild/bundler.js:2474:14
    at /tools/isobuild/bundler.js:2563:20
    at Array.forEach (native)
    at Function._.each._.forEach (/Users/timbroddin/.meteor/packages/meteor-tool/.1.3.2_4.hq6may++os.osx.x86_64+web.browser+web.cordova/mt-os.osx.x86_64/dev_bundle/lib/node_modules/underscore/underscore.js:79:11)
    at /tools/isobuild/bundler.js:2562:7
    at /tools/utils/buildmessage.js:271:13
    at [object Object].withValue (/tools/utils/fiber-helpers.js:89:14)
    at /tools/utils/buildmessage.js:264:29
    at [object Object].withValue (/tools/utils/fiber-helpers.js:89:14)
    at /tools/utils/buildmessage.js:262:18
    at [object Object].withValue (/tools/utils/fiber-helpers.js:89:14)
    at /tools/utils/buildmessage.js:253:23
    at [object Object].withValue (/tools/utils/fiber-helpers.js:89:14)
    at Object.capture (/tools/utils/buildmessage.js:252:19)
    at Object.exports.bundle (/tools/isobuild/bundler.js:2455:31)
    at /tools/runners/run-app.js:591:36
    at Function.run (/tools/tool-env/profile.js:489:12)
    at bundleApp (/tools/runners/run-app.js:581:34)
    at AppRunner._runOnce (/tools/runners/run-app.js:634:35)
    at AppRunner._fiber (/tools/runners/run-app.js:887:28)
    at /tools/runners/run-app.js:411:12
TimBroddin commented 8 years ago

I got it working by commenting out this block in a git checkout of Meteor. Somehow the sourcemap generator got stuck on this.

      // Eager CSS is added unconditionally to a combined <style> tag at
      // the beginning of the <head>. If the corresponding module ever
      // gets imported, its module.exports object should be an empty stub,
      // rather than a <style> node added dynamically to the <head>.
      self.addJavaScript({
        ...options,
        data: "// These styles have already been applied to the document.\n",
        lazy: true
      });

(in tools/isobuild/compiler_plugin.js)

TimBroddin commented 8 years ago

Since this is probably a meteor bug, I made an issue there. I also created a project demonstrating this issue: https://github.com/TimBroddin/meteor-css-modules-bug

meteor/meteor#6881

akanix42 commented 8 years ago

Meteor 1.3.2 changes the way css files are imported. :frowning: I've got some more digging to do, but for now you can probably make it work by changing the outputJsFilePath option in package.json:

"cssModules": {
  "outputJsFilePath": "{dirname}/{basename}{extname}.js"
}

Thanks for digging into it!

TimBroddin commented 8 years ago

Thanks for the quick reply!

newswim commented 8 years ago

I tried just changing the "outputJsFilePath" key in package.json and... complains it can't find files, then the 'attempting to combine different files' error from Meteor. A similar issue was occurring when I tried adding Stylus support, here's my output:

Click to see the thrown error ``` => Started proxy. => Started MongoDB. [Error: File 'control' not found at any of the following paths: ["control","control.scss","control.sass","./_control","./_control.scss","./_control.sass"]] [Error: File 'spinner' not found at any of the following paths: ["spinner","spinner.scss","spinner.sass","./_spinner","./_spinner.scss","./_spinner.sass"]] [Error: File 'select' not found at any of the following paths: ["select","select.scss","select.sass","./_select","./_select.scss","./_select.sass"]] [Error: File 'mixins' not found at any of the following paths: ["mixins","mixins.scss","mixins.sass","./_mixins","./_mixins.scss","./_mixins.sass"]] /Users/dm/.meteor/packages/nathantreid_css-modules/.1.1.1.1wi05i8++os.osx.x86_64+web.browser+web.cordova/plugin.mss.os.osx.x86_64/npm/node_modules/meteor/promise/node_modules/meteor-promise/promise_server.js:116 throw error; ^ Error: Attempting to combine different files: { type: 'js', sourcePath: 'client/modules/core/components/home.scss', servePath: 'client/modules/core/components/home.scss', installPath: 'client/modules/core/components/home.scss', deps: { './home.css': {} }, lazy: true, data: , hash: '9f0931d761f0e9b32f621ea4e0f6c0ce3e7396a9' } { type: 'js', data: , sourcePath: 'client/modules/core/components/home.scss', targetPath: 'client/modules/core/components/home.scss', servePath: '/client/modules/core/components/home.scss', hash: '780b19bffa7eacaba06aea4c3313e683e83146e4', sourceMap: undefined, lazy: false, bare: false, mainModule: false, imported: true, installPath: 'client/modules/core/components/home.scss' } ```

package.json:

  "cssModules": {
    "extensions": [
      "mss",
      "scss",
      "m.styl"
    ],
    "globalVariables": [
      "node_modules/react-toolbox/lib/_colors.scss",
      {
        "theme-building": true
      },
      "client/toolbox-theme.scss"
    ],
    "outputJsFilePath": {
      ".*node_modules/.*": "{dirname}/{basename}{extname}.js"
    },
    "explicitIncludes": [
      "node_modules/react-toolbox"
    ]
  }

Downgrading to 1.3.1 in the meantime.

akanix42 commented 8 years ago

This one has proven to be bigger than I expected (and life is pretty busy right now). I will probably have a fix or workaround sometime this week.

TimBroddin commented 8 years ago

@nathantreid thanks a lot, I'll keep using my patched up Meteor version until then :)

gadicc commented 8 years ago

Hey all, for me I solved both issues (either "Attempting to combine different files" or "Cannot find module") with the following (i.e. no {extname} in there).

    "outputJsFilePath": {
      "node_modules/.*": "{dirname}/{basename}.js"
    },

Hope this helps! Let us know.

newswim commented 8 years ago

@gadicc that's working on 1.3.2.4?

gadicc commented 8 years ago

Yup!

METEOR@1.3.2.4
nathantreid:css-modules@1.1.1*

* Except if you get a TypeError: Cannot call method 'substr' of undefined, I had to modify the package to fix this, as per https://github.com/nathantreid/meteor-react-toolbox-example/issues/4#issuecomment-213738655.

akanix42 commented 8 years ago

This has been fixed in 1.1.2.