Skip to content

Commit

Permalink
fix: running typescript in node
Browse files Browse the repository at this point in the history
  • Loading branch information
stoffeastrom committed Aug 9, 2018
1 parent 8b6cb15 commit 1712cf5
Show file tree
Hide file tree
Showing 14 changed files with 38 additions and 6 deletions.
3 changes: 2 additions & 1 deletion aw.config.js
Expand Up @@ -85,8 +85,9 @@ module.exports = {
['@babel/preset-env', {
targets: {
browsers: ['last 2 versions', 'safari >= 7'],
node: 'current',
},
modules: false,
modules: cmd !== 'chrome' ? 'commonjs' : false,
}],
],
},
Expand Down
2 changes: 1 addition & 1 deletion commands-common/transform/src/index.js
Expand Up @@ -18,7 +18,7 @@ function getBabelOpts(filename, argv) {

function transformTypescript(filePath, sourceRoot, tsContent, argv) {
const { babel: { typescript } } = argv;
const { transform: { typescript: { compilerOptions, babelOptions } } } = argv;
const { transform: { typescript: { compilerOptions = {}, babelOptions = {} } = {} } = {} } = argv;
const fileName = filePath;
compilerOptions.sourceRoot = sourceRoot;
compilerOptions.inlineSources = true;
Expand Down
2 changes: 1 addition & 1 deletion examples/node/README.md → examples/node-js/README.md
Expand Up @@ -3,7 +3,7 @@
## From the project root run

```shell
npm run test
npm run test:node
```

![](./node.gif)
Expand Down
File renamed without changes
File renamed without changes
File renamed without changes
5 changes: 2 additions & 3 deletions examples/node/package.json → examples/node-js/package.json
@@ -1,9 +1,8 @@
{
"name": "@after-work.js/example-node",
"name": "@after-work.js/example-node-js",
"private": true,
"version": "5.0.0-beta.2",
"description": "File utils",
"main": "src/index.js",
"description": "Node example with javascript",
"scripts": {
"lint": "eslint test"
},
Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
16 changes: 16 additions & 0 deletions examples/node-ts/package.json
@@ -0,0 +1,16 @@
{
"name": "@after-work.js/example-node-ts",
"private": true,
"version": "5.0.0-beta.2",
"description": "Node example with typescript",
"repository": {
"type": "git",
"url": "git+ssh://git@github.com/qlik-oss/after-work.js.git"
},
"author": "QlikTech International AB",
"license": "MIT",
"bugs": {
"url": "https://github.com/qlik-oss/after-work.js/issues"
},
"homepage": "https://github.com/qlik-oss/after-work.js#readme"
}
7 changes: 7 additions & 0 deletions examples/node-ts/src/dummy.ts
@@ -0,0 +1,7 @@
export default class Dummy {
private privateMethod() {}
protected protectedMethod() {}
publicMethod() {
return 'dummy';
}
}
9 changes: 9 additions & 0 deletions examples/node-ts/test/dummy.spec.ts
@@ -0,0 +1,9 @@
import { expect } from 'chai';
import Dummy from '../src/dummy';

describe('Dummy', () => {
it('should work with typescript', () => {
const dummy = new Dummy();
expect(dummy.publicMethod()).to.equal('dummy');
});
});

0 comments on commit 1712cf5

Please sign in to comment.