Skip to content

Commit a427c16

Browse files
fix bug when plugin is used without options
1 parent c122965 commit a427c16

File tree

1 file changed

+3
-3
lines changed

1 file changed

+3
-3
lines changed

src/index.js

+3-3
Original file line numberDiff line numberDiff line change
@@ -180,7 +180,7 @@ export default function transformCssModules({ types: t }) {
180180
]
181181
);
182182

183-
if (thisPluginOptions.keepImport === true) {
183+
if (thisPluginOptions && thisPluginOptions.keepImport === true) {
184184
path.parentPath.replaceWithMultiple([
185185
t.expressionStatement(
186186
t.callExpression(
@@ -216,7 +216,7 @@ export default function transformCssModules({ types: t }) {
216216
path.replaceWith(buildClassNameToScopeNameMap(tokens));
217217

218218
// Keeped import will places before closest expression statement child
219-
if (thisPluginOptions.keepImport === true) {
219+
if (thisPluginOptions && thisPluginOptions.keepImport === true) {
220220
findExpressionStatementChild(path, t).insertBefore(
221221
t.expressionStatement(
222222
t.callExpression(
@@ -226,7 +226,7 @@ export default function transformCssModules({ types: t }) {
226226
)
227227
);
228228
}
229-
} else if (thisPluginOptions.keepImport !== true) {
229+
} else if (!thisPluginOptions || thisPluginOptions.keepImport !== true) {
230230
path.remove();
231231
}
232232
}

0 commit comments

Comments
 (0)