Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 8 additions & 2 deletions src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -71,9 +71,15 @@ module.exports = (
// we need to catch here because the plugin will
// error if there's no tsconfig in the working directory
try {
resolvePlugins.push(new TsconfigPathsPlugin({ silent: true }));

const tsconfig = tsconfigPaths.loadConfig();
const fullTsconfig = require(tsconfig.configFileAbsolutePath)

const tsconfigPathsOptions = { silent: true }
if (fullTsconfig.compilerOptions.allowJs) {
tsconfigPathsOptions.extensions = SUPPORTED_EXTENSIONS
}
resolvePlugins.push(new TsconfigPathsPlugin(tsconfigPathsOptions));

if (tsconfig.resultType === "success") {
tsconfigMatchPath = tsconfigPaths.createMatchPath(tsconfig.absoluteBaseUrl, tsconfig.paths);
}
Expand Down
3 changes: 3 additions & 0 deletions test/unit/tsconfig-paths-allowjs/input.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
import module from '@module';

console.log(module);
1 change: 1 addition & 0 deletions test/unit/tsconfig-paths-allowjs/module.js
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
export default {};
86 changes: 86 additions & 0 deletions test/unit/tsconfig-paths-allowjs/output-coverage.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,86 @@
module.exports =
/******/ (function(modules, runtime) { // webpackBootstrap
/******/ "use strict";
/******/ // The module cache
/******/ var installedModules = {};
/******/
/******/ // The require function
/******/ function __webpack_require__(moduleId) {
/******/
/******/ // Check if module is in cache
/******/ if(installedModules[moduleId]) {
/******/ return installedModules[moduleId].exports;
/******/ }
/******/ // Create a new module (and put it into the cache)
/******/ var module = installedModules[moduleId] = {
/******/ i: moduleId,
/******/ l: false,
/******/ exports: {}
/******/ };
/******/
/******/ // Execute the module function
/******/ modules[moduleId].call(module.exports, module, module.exports, __webpack_require__);
/******/
/******/ // Flag the module as loaded
/******/ module.l = true;
/******/
/******/ // Return the exports of the module
/******/ return module.exports;
/******/ }
/******/
/******/
/******/ __webpack_require__.ab = __dirname + "/";
/******/
/******/ // the startup function
/******/ function startup() {
/******/ // Load entry module and return exports
/******/ return __webpack_require__(439);
/******/ };
/******/ // initialize runtime
/******/ runtime(__webpack_require__);
/******/
/******/ // run startup
/******/ return startup();
/******/ })
/************************************************************************/
/******/ ({

/***/ 306:
/***/ (function(__unusedmodule, __webpack_exports__, __webpack_require__) {

"use strict";
__webpack_require__.r(__webpack_exports__);
/* harmony default export */ __webpack_exports__["default"] = ({});


/***/ }),

/***/ 439:
/***/ (function(__unusedmodule, exports, __webpack_require__) {

"use strict";

exports.__esModule = true;
var _module_1 = __webpack_require__(306);
console.log(_module_1["default"]);


/***/ })

/******/ },
/******/ function(__webpack_require__) { // webpackRuntimeModules
/******/ "use strict";
/******/
/******/ /* webpack/runtime/make namespace object */
/******/ !function() {
/******/ // define __esModule on exports
/******/ __webpack_require__.r = function(exports) {
/******/ if(typeof Symbol !== 'undefined' && Symbol.toStringTag) {
/******/ Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
/******/ }
/******/ Object.defineProperty(exports, '__esModule', { value: true });
/******/ };
/******/ }();
/******/
/******/ }
);
66 changes: 66 additions & 0 deletions test/unit/tsconfig-paths-allowjs/output.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,66 @@
module.exports =
/******/ (function(modules, runtime) { // webpackBootstrap
/******/ "use strict";
/******/ // The module cache
/******/ var installedModules = {};
/******/
/******/ // The require function
/******/ function __webpack_require__(moduleId) {
/******/
/******/ // Check if module is in cache
/******/ if(installedModules[moduleId]) {
/******/ return installedModules[moduleId].exports;
/******/ }
/******/ // Create a new module (and put it into the cache)
/******/ var module = installedModules[moduleId] = {
/******/ i: moduleId,
/******/ l: false,
/******/ exports: {}
/******/ };
/******/
/******/ // Execute the module function
/******/ modules[moduleId].call(module.exports, module, module.exports, __webpack_require__);
/******/
/******/ // Flag the module as loaded
/******/ module.l = true;
/******/
/******/ // Return the exports of the module
/******/ return module.exports;
/******/ }
/******/
/******/
/******/ __webpack_require__.ab = __dirname + "/";
/******/
/******/ // the startup function
/******/ function startup() {
/******/ // Load entry module and return exports
/******/ return __webpack_require__(468);
/******/ };
/******/
/******/ // run startup
/******/ return startup();
/******/ })
/************************************************************************/
/******/ ({

/***/ 17:
/***/ (function() {

eval("require")("@module");


/***/ }),

/***/ 468:
/***/ (function(__unusedmodule, exports, __webpack_require__) {

"use strict";

exports.__esModule = true;
var _module_1 = __webpack_require__(17);
console.log(_module_1["default"]);


/***/ })

/******/ });
11 changes: 11 additions & 0 deletions test/unit/tsconfig-paths-allowjs/tsconfig.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
{
"compilerOptions": {
"module": "commonjs",
"moduleResolution": "node",
"baseUrl": ".",
"paths": {
"@*": ["./*"]
},
"allowJs": true
}
}