Skip to content
This repository has been archived by the owner on Nov 16, 2023. It is now read-only.

start-dev launch option (ts-node-dev) #234

Open
wants to merge 234 commits into
base: master
Choose a base branch
from

Conversation

GrayStrider
Copy link
Contributor

allows to work on project without re-building each time

Bowden Kelly and others added 30 commits May 9, 2017 13:28
Update references from bowdenk7 repo to Microsoft repo
added package-lock for npm5 and fixed bug with flash messages
Added `build` `preLaunchTask` for debug configuration
Removed duplication in npm scripts `serve` and `watch`
…MaxOptions'.

fix err TypeScript-Node-Starter/src/controllers/api.ts[6, 9]: missing whitespace, 8 files
fix bugs of issue 15
fit  bugs of issue 15 and some other bugs caused by tslint
port changes from PR microsoft#11 and update package.lock from latest npm version
Orta and others added 16 commits July 15, 2019 17:08
…lash-types

Simplify augmented module for express-flash
…-nodejs-versions

Specify NodeJS version as strings in Travis configuration
📝 remove reference to legacy file. Closes microsoft#190
This commit rewrites linting support in the project to be based solely
on the ESLint as advised by the TSLint tool authors:
https://medium.com/palantir/tslint-in-2019-1a144c2317a9

The migration is based on default, recommended settings for TypeScript
in ESLint and is expected to be updated in future to better fit project
goals.

All references has been updated and replaced with relevant ESLint
context:

- dependencies migration from TSLint to ESLint
- VSCode configuration changes to support ESLint exension
- VSCode extensions recommendation changes
- `.eslintrc` and `.eslintignore` configuration files added
- all error level problems in the source files are covered by this
  migration

Thanks!
fix lint error
```
PS> npm run lint                                                                                                        
> [email protected] lint C:\Users\JipingWang\source\repos\api
> tsc --noEmit && eslint '*/**/*.{js,ts}' --quiet --fix


Oops! Something went wrong! :(

ESLint: 5.16.0.
No files matching the pattern "'*/**/*.{js,ts}'" were found.
Please check for typing mistakes in the pattern.

npm ERR! code ELIFECYCLE
npm ERR! errno 2
npm ERR! [email protected] lint: `tsc --noEmit && eslint '*/**/*.{js,ts}' --quiet --fix`
npm ERR! Exit status 2
npm ERR!
npm ERR! Failed at the [email protected] lint script.
npm ERR! This is probably not a problem with npm. There is likely additional logging output above.

npm ERR! A complete log of this run can be found in:
npm ERR!     C:\Users\JipingWang\AppData\Roaming\npm-cache\_logs\2019-07-18T15_26_05_580Z-debug.log
```
…rn/eslint-utils-1.4.2

Bump eslint-utils from 1.4.0 to 1.4.2
Use update indexes access in Mongoose configuration. Fixes microsoft#225
- upgrade to latest packages
- cast `req.user` as `UserDocument`
- update logger to use latest Winston syntax
- disable `no-inferrable-types`, Mongoose use unified topology

Thx to @CarlosSolrac
@GrayStrider GrayStrider force-pushed the patch-nodemon branch 2 times, most recently from 5a58703 to 2299dc1 Compare October 6, 2019 13:39
Copy link
Collaborator

@peterblazejewicz peterblazejewicz left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If accepted, it would require solution for serving static assets from public directory. At the moment, content usually pre-built like css (from scss) could not be used when started in that mode.
For example such minimal change does the trick, but is just a pointer on how to achieve this, could be better one:

  • add cross-env as dev dependency
"start-dev": "cross-env NODE_ENV=development dotenv -- nodemon -e ts -x ts-node --files src/server.ts"

app.ts:

const staticAssetsRoot = (process.env.NODE_ENV === "development") ?
    path.join(__dirname, "../dist") :
    __dirname;

app.use(
    express.static(path.join(staticAssetsRoot, "public"), { maxAge: 31557600000 })
);

package.json Outdated Show resolved Hide resolved
@GrayStrider GrayStrider changed the title start-dev launch option (nodemon, node-ts) start-dev launch option (nodemon, ts-node) Oct 10, 2019
@GrayStrider
Copy link
Contributor Author

GrayStrider commented Oct 10, 2019

If accepted, it would require solution for serving static assets from public directory. At the moment, content usually pre-built like css (from scss) could not be used when started in that mode.

@peterblazejewicz
I just launched it and everything seems to work fine? No unresolved resources or anything, css seems to be built as well.

image

perhaps, --files option takes care of things? Could someone test it and see what exactly doesn't work, if anything?

@GrayStrider
Copy link
Contributor Author

Nevermind, found a much better option, one sec

@@ -10,7 +10,7 @@
"license": "MIT",
"scripts": {
"start": "npm run serve",
"start-dev": "dotenv -- nodemon -e ts -x ts-node --files src/server.ts",
"start-dev": "dotenv -- ts-node-dev --watch views src/server.ts",
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

takes a few seconds to reload after changes, unlike nodemon;
--watch views will also trigger reload on any change in views folder (still need to refresh the page to see them)
unfortunatelly, couldn't make it trigger refresh on scss changes in public folder (--watch public,views), works when putting scss in views folder though.

@GrayStrider GrayStrider changed the title start-dev launch option (nodemon, ts-node) start-dev launch option (ts-node-dev) Oct 10, 2019
@GrayStrider
Copy link
Contributor Author

Are there any other adjustments needs to be made?

@anthony-bernardo
Copy link

why this is not merged ? this is a must have when you are working on a project

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet