From 8496c01b034e53c8f644fcd4cac3b1b16cd98647 Mon Sep 17 00:00:00 2001 From: AlbertLucianto Date: Tue, 19 Feb 2019 05:09:03 +0800 Subject: [PATCH 1/4] fix: cannot read property 'split' of undefined --- src/getClassName.js | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/getClassName.js b/src/getClassName.js index d99d858..7420a09 100644 --- a/src/getClassName.js +++ b/src/getClassName.js @@ -72,6 +72,8 @@ export default (styleNameValue: string, styleModuleImportMap: StyleModuleImportM const handleMissingStyleName = options && options.handleMissingStyleName || DEFAULT_HANDLE_MISSING_STYLENAME_OPTION; + if (!styleNameValue) return ''; + return styleNameValue .split(' ') .filter((styleName) => { From 9b8ed7d646b9c4aaf4a4512b70421f766e4e2799 Mon Sep 17 00:00:00 2001 From: AlbertLucianto Date: Tue, 19 Feb 2019 13:09:38 +0800 Subject: [PATCH 2/4] fix: lint error in getClassName --- src/getClassName.js | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/getClassName.js b/src/getClassName.js index 7420a09..f1cfd00 100644 --- a/src/getClassName.js +++ b/src/getClassName.js @@ -72,7 +72,9 @@ export default (styleNameValue: string, styleModuleImportMap: StyleModuleImportM const handleMissingStyleName = options && options.handleMissingStyleName || DEFAULT_HANDLE_MISSING_STYLENAME_OPTION; - if (!styleNameValue) return ''; + if (!styleNameValue) { + return ''; + }; return styleNameValue .split(' ') From b6155cabb50d13bad0241c82d2f818c2c7b91a9d Mon Sep 17 00:00:00 2001 From: AlbertLucianto Date: Tue, 19 Feb 2019 13:23:00 +0800 Subject: [PATCH 3/4] fix: lint error in getClassName --- src/getClassName.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/getClassName.js b/src/getClassName.js index f1cfd00..87e29cd 100644 --- a/src/getClassName.js +++ b/src/getClassName.js @@ -74,7 +74,7 @@ export default (styleNameValue: string, styleModuleImportMap: StyleModuleImportM if (!styleNameValue) { return ''; - }; + } return styleNameValue .split(' ') From 4355b118bc49914e1aca56254a69d385d8f02034 Mon Sep 17 00:00:00 2001 From: AlbertLucianto Date: Wed, 20 Feb 2019 01:31:53 +0800 Subject: [PATCH 4/4] test: add test case for absolute import --- package.json | 1 + .../resolves absolute path stylesheets/bar.css | 1 + .../resolves absolute path stylesheets/input.js | 3 +++ .../options.json | 15 +++++++++++++++ .../resolves absolute path stylesheets/output.js | 5 +++++ 5 files changed, 25 insertions(+) create mode 100644 test/fixtures/react-css-modules/resolves absolute path stylesheets/bar.css create mode 100644 test/fixtures/react-css-modules/resolves absolute path stylesheets/input.js create mode 100644 test/fixtures/react-css-modules/resolves absolute path stylesheets/options.json create mode 100644 test/fixtures/react-css-modules/resolves absolute path stylesheets/output.js diff --git a/package.json b/package.json index 1e05fae..bcc2393 100644 --- a/package.json +++ b/package.json @@ -29,6 +29,7 @@ "@babel/register": "^7.0.0", "babel-core": "^7.0.0-bridge.0", "babel-jest": "^23.6.0", + "babel-plugin-module-resolver": "^3.2.0", "babel-plugin-tester": "^5.5.1", "eslint": "^5.5.0", "eslint-config-canonical": "^12.0.0", diff --git a/test/fixtures/react-css-modules/resolves absolute path stylesheets/bar.css b/test/fixtures/react-css-modules/resolves absolute path stylesheets/bar.css new file mode 100644 index 0000000..5512dae --- /dev/null +++ b/test/fixtures/react-css-modules/resolves absolute path stylesheets/bar.css @@ -0,0 +1 @@ +.a {} diff --git a/test/fixtures/react-css-modules/resolves absolute path stylesheets/input.js b/test/fixtures/react-css-modules/resolves absolute path stylesheets/input.js new file mode 100644 index 0000000..74e3ca8 --- /dev/null +++ b/test/fixtures/react-css-modules/resolves absolute path stylesheets/input.js @@ -0,0 +1,3 @@ +import 'abs/bar.css'; + +
; diff --git a/test/fixtures/react-css-modules/resolves absolute path stylesheets/options.json b/test/fixtures/react-css-modules/resolves absolute path stylesheets/options.json new file mode 100644 index 0000000..b3f5043 --- /dev/null +++ b/test/fixtures/react-css-modules/resolves absolute path stylesheets/options.json @@ -0,0 +1,15 @@ +{ + "plugins": [ + ["module-resolver", { + "alias": { + "abs": "./test/fixtures/react-css-modules/resolves absolute path stylesheets" + } + }], + [ + "../../../../src", + { + "generateScopedName": "[name]__[local]" + } + ] + ] +} diff --git a/test/fixtures/react-css-modules/resolves absolute path stylesheets/output.js b/test/fixtures/react-css-modules/resolves absolute path stylesheets/output.js new file mode 100644 index 0000000..29a37b6 --- /dev/null +++ b/test/fixtures/react-css-modules/resolves absolute path stylesheets/output.js @@ -0,0 +1,5 @@ +"use strict"; + +require("./bar.css"); + +
;