Skip to content

Commit 482218c

Browse files
committed
Don't use tsconfig-paths-webpack-plugin if no baseUrl defined
1 parent 037b521 commit 482218c

File tree

8 files changed

+70
-6
lines changed

8 files changed

+70
-6
lines changed

src/webpack.config.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -299,7 +299,7 @@ function plugins() {
299299

300300
if (ENABLE_LINTING) {
301301
if (parsedTsConfig.exclude) {
302-
tsEslintConfig.ignorePatterns = parsedTsConfig.exclude
302+
tsEslintConfig.ignorePatterns = parsedTsConfig.exclude;
303303
}
304304
forkTsCheckerWebpackOptions.eslint = {
305305
files: path.join(servicePath, "**/*.ts"),
@@ -413,7 +413,7 @@ function plugins() {
413413
function resolvePlugins() {
414414
const plugins = [];
415415

416-
if (ENABLE_TYPESCRIPT) {
416+
if (ENABLE_TYPESCRIPT && (parsedTsConfig.options || {}).baseUrl) {
417417
plugins.push(
418418
new TsconfigPathsPlugin({
419419
configFile: tsConfigPath,

tests/helpers/run-sls-command.js

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -6,15 +6,17 @@ const execPromise = promisify(exec);
66
const TIMEOUT = 30000;
77
const INVOKE_CMD = "invoke local -f hello -l --data {}";
88

9-
async function runSlsCommand(cwd, cmd = INVOKE_CMD) {
9+
async function runSlsCommand(cwd, cmd = INVOKE_CMD, includeStderr = false) {
1010
await npmInstall(cwd);
1111

12-
const { stdout } = await execPromise(`serverless ${cmd}`, {
12+
const { stdout, stderr } = await execPromise(`serverless ${cmd}`, {
1313
cwd,
14-
TIMEOUT
14+
TIMEOUT,
1515
});
1616

17-
return stdout.toString("utf8");
17+
return includeStderr
18+
? stdout.toString("utf8") + stderr.toString("utf8")
19+
: stdout.toString("utf8");
1820
}
1921

2022
module.exports = runSlsCommand;
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
export const hello = async (event: any) => {
2+
return {
3+
statusCode: 200,
4+
body: JSON.stringify({
5+
message: "No baseUrl",
6+
input: event,
7+
}),
8+
};
9+
};

tests/typescript-no-baseUrl/package-lock.json

Lines changed: 5 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
{
2+
"name": "typescript-no-baseUrl",
3+
"version": "1.0.0",
4+
"description": "",
5+
"main": "handler.js",
6+
"scripts": {
7+
"test": "echo \"Error: no test specified\" && exit 1"
8+
},
9+
"keywords": [],
10+
"author": "",
11+
"license": "ISC"
12+
}
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
service: my-service
2+
3+
plugins:
4+
- '../../index'
5+
6+
custom:
7+
8+
provider:
9+
name: aws
10+
runtime: nodejs12.x
11+
12+
functions:
13+
hello:
14+
handler: handler.hello
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
{
2+
"compilerOptions": {
3+
"target": "es6",
4+
"moduleResolution": "node"
5+
}
6+
}
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
const { runSlsCommand, clearNpmCache } = require("../helpers");
2+
3+
beforeEach(async () => {
4+
await clearNpmCache(__dirname);
5+
});
6+
7+
afterAll(async () => {
8+
await clearNpmCache(__dirname);
9+
});
10+
11+
test("typescript-no-baseUrl", async () => {
12+
const result = await runSlsCommand(__dirname, "package", true);
13+
14+
expect(result).not.toMatch(/Failed to load/);
15+
expect(result).not.toMatch(/Found no baseUrl/);
16+
});

0 commit comments

Comments
 (0)