From b4fe0d5c85aa84df3a8b993e5e2358580cc94f5a Mon Sep 17 00:00:00 2001 From: Ben Newman Date: Mon, 4 Apr 2016 21:10:02 -0400 Subject: [PATCH] Allow importing .css files from node_modules directories. Fixes #6037. --- tools/isobuild/compiler-plugin.js | 18 ++++++--- tools/isobuild/css-modules.js | 65 +++++++++++++++++++++++++++++++ tools/isobuild/import-scanner.js | 14 ++++++- tools/tests/apps/modules/tests.js | 12 +++--- tools/tool-env/isopackets.js | 9 +++-- 5 files changed, 100 insertions(+), 18 deletions(-) create mode 100644 tools/isobuild/css-modules.js diff --git a/tools/isobuild/compiler-plugin.js b/tools/isobuild/compiler-plugin.js index d550fdbe7b2..3055eb697f2 100644 --- a/tools/isobuild/compiler-plugin.js +++ b/tools/isobuild/compiler-plugin.js @@ -14,6 +14,7 @@ import Fiber from 'fibers'; import {sourceMapLength} from '../utils/utils.js'; import {Console} from '../console/console.js'; import ImportScanner from './import-scanner.js'; +import {cssToCommonJS} from "./css-modules.js"; import { isTestFilePath } from './test-files.js'; @@ -482,15 +483,22 @@ class ResourceSlot { // unconditionally as a CSS resource, so that it can be imported // when needed. resource.type = "js"; - resource.data = new Buffer( - 'module.exports = require("meteor/modules").addStyles(' + - JSON.stringify(data) + ');\n', - 'utf8' - ); + resource.data = + new Buffer(cssToCommonJS(data, resource.hash), "utf8"); self.jsOutputResources.push(resource); } else { + // Eager CSS is added unconditionally to a combined