Fix VSCode Launch Task and Monorepo builds (#193)

* revise vscode task and launch configs

- Removed commands from sub-package:
  same can be achieved from the root
- Added build and no-build variants.
  In case separate watcher is already running,
  no need to build.
- Changed watch to build (no hot-reload in vscode by default)
- Show the build in console

Didn't update yarn.lock, seems to want to add
foam-core@0.3.0-alpha.0, but not really
related to this change

Note: the extension tests are failing due to
`Cannot find module '...foam-vscode/out/test/suite/index'`.
However that shouldn't be related to this change either.

* Simplify VS Code launch tasks (shift work to typescript compiler)

* Fix circular dependency index->janitor/index->index

* Use --build flag to use TSC in Build Mode
https://www.typescriptlang.org/docs/handbook/project-references.html#build-mode-for-typescript

This configures tsc to use multiple project roots (vscode, core) and run incremental builds on
changes to each projects. This will necessitate us running the core in commonjs build mode,
which is fine for testing and deployment to node environments, but won't work in the browser,
so foam-core will need a separate build config for UMD builds

* Build foam-core in commonjs mode by default (+cleanup unnecessary config)

* Create ES6 build config for distribution builds

* Cleanup yarn.lock

* Build package before running

* Fix missing lint paths and fix lint error

* Remove redundant .vscode settings files from foam-vscode project

* Add core test launch task

Co-authored-by: jojanaho <janne.ojanaho@iki.fi>
This commit is contained in:
Jani Eväkallio
2020-07-30 21:39:16 +01:00
committed by GitHub
parent 49ddc41d41
commit 0e0355ae9f
15 changed files with 72 additions and 163 deletions

23
.vscode/launch.json vendored
View File

@@ -6,10 +6,8 @@
"version": "0.2.0",
"configurations": [
{
// This task is also defined in packages/foam-vscode/.vscode/launch.json
// for when running separately outside of the monorepo environment
"name": "Run Extension",
"type": "extensionHost",
"name": "Run VSCode Extension",
"type": "extensionHost",
"request": "launch",
"runtimeExecutable": "${execPath}",
"args": [
@@ -18,12 +16,14 @@
"outFiles": [
"${workspaceFolder}/packages/foam-vscode/out/**/*.js"
],
"preLaunchTask": "Build foam-vscode"
"preLaunchTask": "${defaultBuildTask}"
},
// @NOTE: This task is broken. VSCode e2e tests are currently disabled
// due to incompability of jest and mocha inside a typescript monorepo
// Contributions to fix this are welcome!
{
// This task is also defined in packages/foam-vscode/.vscode/launch.json
// for when running separately outside of the monorepo environment
"name": "Extension Tests",
"name": "Test VSCode Extension",
"type": "extensionHost",
"request": "launch",
"runtimeExecutable": "${execPath}",
@@ -34,16 +34,17 @@
"outFiles": [
"${workspaceFolder}/packages/foam-vscode/out/test/**/*.js"
],
"preLaunchTask": "Build foam-vscode"
"preLaunchTask": "${defaultBuildTask}"
},
{
"name": "Test Core",
"type": "node",
"request": "launch",
"name": "Workspace Manager tests",
"program": "${workspaceFolder}/node_modules/tsdx/dist/index.js",
"args": ["test"],
"cwd": "${workspaceFolder}/packages/foam-core",
"internalConsoleOptions": "openOnSessionStart"
"internalConsoleOptions": "openOnSessionStart",
"preLaunchTask": "${defaultBuildTask}"
}
]
}

29
.vscode/tasks.json vendored
View File

@@ -4,19 +4,28 @@
"version": "2.0.0",
"tasks": [
{
// This task is also defined in packages/foam-vscode/.vscode/tasks.json
// for when running separately outside of the monorepo environment
"type": "npm",
"script": "watch",
"label": "Build foam-vscode",
"path": "packages/foam-vscode",
"problemMatcher": "$tsc-watch",
"label": "watch: foam-vscode",
"type": "npm",
"script": "start:vscode",
"problemMatcher": "$tsc-watch",
"isBackground": true,
"presentation": {
"reveal": "silent",
"revealProblems": "onProblem",
"focus": true
"reveal": "always"
},
"group": {
"kind": "build",
"isDefault": true
}
},
{
"label": "test: all packages",
"type": "npm",
"script": "test",
"problemMatcher": [],
"group": {
"kind": "test",
"isDefault": true
},
}
]
}

View File

@@ -10,7 +10,7 @@
"packages/*"
],
"scripts": {
"watch:vscode": "yarn workspace foam-vscode watch",
"start:vscode": "yarn workspace foam-vscode vscode:start-debugging",
"build:core": "yarn workspace foam-core build",
"watch:core": "yarn workspace foam-core start",
"test:core": "yarn workspace foam-core test",

View File

@@ -63,7 +63,7 @@
"build": "tsc -b",
"test": "jest",
"lint": "echo Missing lint task in CLI package",
"cli": "./bin/run",
"cli": "yarn build && ./bin/run",
"postpack": "rm -f oclif.manifest.json",
"prepack": "rm -rf lib && tsc -b && oclif-dev manifest && oclif-dev readme",
"version": "oclif-dev readme && git add README.md"

View File

@@ -9,9 +9,9 @@
],
"scripts": {
"clean": "rimraf dist",
"build": "tsdx build",
"build": "tsdx build --tsconfig ./tsconfig.build.json",
"test": "tsdx test",
"lint": "tsdx lint",
"lint": "tsdx lint src test",
"watch": "tsdx watch",
"prepare": "tsdx build"
},

View File

@@ -1,11 +1,10 @@
import { Position } from 'unist';
import GithubSlugger from 'github-slugger';
import { Note, NoteGraph } from '../note-graph';
import {
Note,
NoteGraph,
LINK_REFERENCE_DEFINITION_HEADER,
LINK_REFERENCE_DEFINITION_FOOTER,
} from '../index';
} from '../definitions';
import {
createMarkdownReferences,
stringifyMarkdownLinkReferenceDefinition,

View File

@@ -0,0 +1,6 @@
{
"extends": "./tsconfig.json",
"compilerOptions": {
"module": "es6"
}
}

View File

@@ -1,34 +1,29 @@
{
"extends": "../../tsconfig.base.json",
"compilerOptions": {
"baseUrl": "src",
"composite": true,
"esModuleInterop": true,
"importHelpers": true,
// commonjs module format is used so that the incremental
// tsc build-mode ran during development can replace individual
// files (as opposed to generate the .cjs.development.js bundle.
//
// this is overridden in tsconfig.build.json for distribution
"module": "commonjs",
"moduleResolution": "node",
"outDir": "dist",
"rootDir": "./src",
"sourceMap": true,
"strict": true,
"lib": [
"esnext"
]
},
"include": [
"src",
"types"
],
"compilerOptions": {
"composite": true,
"declaration": true,
"declarationMap": true,
// to override config from tsconfig.base.json
"outDir": "dist",
"rootDir": "./src",
// for references
"baseUrl": "src",
"lib": [
"esnext"
],
"module": "esnext",
"importHelpers": true,
"sourceMap": true,
"strict": true,
// "noUnusedLocals": true,
"noUnusedParameters": true,
"noImplicitReturns": true,
"noFallthroughCasesInSwitch": true,
"moduleResolution": "node",
"esModuleInterop": true
// "paths": {
// "*": ["src/*", "node_modules/*"]
// },
// "jsx": "react",
},
]
}

View File

@@ -1,7 +0,0 @@
{
// See http://go.microsoft.com/fwlink/?LinkId=827846
// for the documentation about the extensions.json format
"recommendations": [
"dbaeumer.vscode-eslint"
]
}

View File

@@ -1,40 +0,0 @@
// A launch configuration that compiles the extension and then opens it inside a new window
// Use IntelliSense to learn about possible attributes.
// Hover to view descriptions of existing attributes.
// For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387
{
"version": "0.2.0",
"configurations": [
{
// This task is also defined in ${workspaceFolder}/.vscode/launch.json
// for when running in a monorepo environment
"name": "Run Extension",
"type": "extensionHost",
"request": "launch",
"runtimeExecutable": "${execPath}",
"args": [
"--extensionDevelopmentPath=${workspaceFolder}"
],
"outFiles": [
"${workspaceFolder}/out/**/*.js"
],
"preLaunchTask": "${defaultBuildTask}"
},
{
// This task is also defined in ${workspaceFolder}/.vscode/launch.json
// for when running in a monorepo environment
"name": "Extension Tests",
"type": "extensionHost",
"request": "launch",
"runtimeExecutable": "${execPath}",
"args": [
"--extensionDevelopmentPath=${workspaceFolder}",
"--extensionTestsPath=${workspaceFolder}/out/test/suite/index"
],
"outFiles": [
"${workspaceFolder}/out/test/**/*.js"
],
"preLaunchTask": "${defaultBuildTask}"
}
]
}

View File

@@ -1,11 +0,0 @@
// Place your settings in this file to overwrite default and user settings.
{
"files.exclude": {
"out": false // set this to true to hide the "out" folder with the compiled JS files
},
"search.exclude": {
"out": true // set this to false to include "out" folder in search results
},
// Turn off tsc task auto detection since we have the necessary tasks as npm scripts
"typescript.tsc.autoDetect": "off"
}

View File

@@ -1,22 +0,0 @@
// See https://go.microsoft.com/fwlink/?LinkId=733558
// for the documentation about the tasks.json format
{
"version": "2.0.0",
"tasks": [
{
// This task is also defined in ${workspaceFolder}/.vscode/tasks.json
// for when running in a monorepo environment
"type": "npm",
"script": "watch",
"problemMatcher": "$tsc-watch",
"isBackground": true,
"presentation": {
"reveal": "never"
},
"group": {
"kind": "build",
"isDefault": true
}
}
]
}

View File

@@ -88,11 +88,12 @@
]
},
"scripts": {
"clean": "rimraf out",
"build": "tsc -p ./",
"test": "echo No tests in VSCode extensions yet",
"lint": "eslint src --ext ts",
"watch": "tsc -watch -p ./",
"clean": "tsc --build ./tsconfig.json ../foam-core/tsconfig.json --clean",
"watch": "tsc --build ./tsconfig.json ../foam-core/tsconfig.json --watch",
"vscode:start-debugging": "yarn clean && yarn watch",
"vscode:prepublish": "yarn npm-install && yarn run build",
"npm-install": "rimraf node_modules && npm i",
"npm-cleanup": "rimraf package-lock.json node_modules && yarn",

View File

@@ -1,22 +1,16 @@
{
"extends": "../../tsconfig.base.json",
"compilerOptions": {
"module": "commonjs",
"moduleResolution": "node",
"target": "es6",
"esModuleInterop": true,
"outDir": "out",
"lib": ["es6"],
"sourceMap": true,
"rootDir": "src",
"strict": false /* enable all strict type-checking options */
/* Additional Checks */
// "noImplicitReturns": true, /* Report error when not all code paths in function return a value. */
// "noFallthroughCasesInSwitch": true, /* Report errors for fallthrough cases in switch statement. */
// "noUnusedParameters": true, /* Report errors on unused parameters. */
"strict": false
},
"include": ["src"],
"exclude": ["node_modules", ".vscode-test"],
"references": [{
"path": "../foam-core/tsconfig.json"
"path": "../foam-core"
}]
}

View File

@@ -5188,22 +5188,6 @@ flush-write-stream@^1.0.0:
inherits "^2.0.3"
readable-stream "^2.3.6"
foam-core@0.3.0-alpha.0:
version "0.3.0-alpha.0"
resolved "https://registry.yarnpkg.com/foam-core/-/foam-core-0.3.0-alpha.0.tgz#792ef6b344854f6e34af954cbbce0a39c1657712"
integrity sha512-HNCjlb8LtWePry/llLQRm5L8pJGredD6bj3WrILivIwIvYiXhhNzuIdFZkkUQKLcxQawKGBs9SkIapYrAk0rFw==
dependencies:
detect-newline "^3.1.0"
github-slugger "^1.3.0"
glob "^7.1.6"
graphlib "^2.1.8"
lodash "^4.17.19"
remark-parse "^8.0.2"
remark-wiki-link "^0.0.4"
title-case "^3.0.2"
unified "^9.0.0"
unist-util-visit "^2.0.2"
for-in@^1.0.2:
version "1.0.2"
resolved "https://registry.yarnpkg.com/for-in/-/for-in-1.0.2.tgz#81068d295a8142ec0ac726c6e2200c30fb6d5e80"