-
Notifications
You must be signed in to change notification settings - Fork 4.3k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Adds support for ESM tailwind.config.js
files
#3544
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -2,3 +2,4 @@ | |
/docs | ||
/__tests__/fixtures/cli-utils.js | ||
/stubs/* | ||
/src/util/requireOrImportConfig.js |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -94,6 +94,9 @@ | |
} | ||
} | ||
] | ||
], | ||
"exclude": [ | ||
"src/util/requireOrImportConfig.js" | ||
] | ||
}, | ||
"jest": { | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
"use strict"; | ||
|
||
// Node v12.17+ exposes `import` within CJS files | ||
// in order to `require` ESM files. | ||
|
||
// This file is intentionally excluded from `babel` (and `eslint`) | ||
// to avoid transpiling away the `import` statement | ||
|
||
Object.defineProperty(exports, "__esModule", { | ||
value: true | ||
}); | ||
|
||
exports.default = requireOrImportConfig; | ||
|
||
function requireOrImportConfig(config) { | ||
try { | ||
return require(config) | ||
} catch (e) { | ||
if (e.code === 'ERR_REQUIRE_ESM') { | ||
try { | ||
return import(config).then(mdl => mdl.default) | ||
} catch (e) {} | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Similar to my previous comment, maybe just throw the original exception in here if There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @natemoo-re Might you update the pull request, please? |
||
} | ||
} | ||
return null; | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What if it is a different exception? Right now you will return
null
, but I think you should throw the original exception.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good catch, that makes total sense. I will update this!