Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add Typescript support #204

Open
wants to merge 3 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 1 commit
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
15 changes: 14 additions & 1 deletion cli/gulpfile.js
Original file line number Diff line number Diff line change
Expand Up @@ -49,8 +49,21 @@ const script = ({src, name, mode}, done = _ => true) => {
devtool: isProd ? undefined : 'cheap-source-map',
// allow TS importing
resolve: {
extensions: ['.ts', '...']
extensions: ['.ts', '.tsx', '...']
},
// use ts-loader to compile TS files
module: {
rules: [
// all files with a `.ts`, `.cts`, `.mts` or `.tsx` extension will be handled by `ts-loader`
{
test: /\.([cm]?ts|tsx)$/,
loader: 'ts-loader',
options: {
configFile: 'src/tsconfig.json'
}
}
]
}
};

return gulp.src(src)
Expand Down
8 changes: 8 additions & 0 deletions guide/03-xt-build.md
Copy link
Author

Choose a reason for hiding this comment

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

Future todo: Automatically add on xt-create?

Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,14 @@ xt-build {-e|--env} dev {-w|--watch}
xt-build --help
```

## TypeScript notes

You may use either TypeScript (`.ts`, `.tsx`) or JavaScript files. However, if any TypeScript is used, you must add
`tsconfig.json` to the `src` directory.

In this config file, you do not need to add anything (unless you want to change any settings). However, without it,
compilation will fail.

## Package.json scripts

After adding Extension CLI to your project, you can run these commands from a
Expand Down
123 changes: 118 additions & 5 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -102,6 +102,7 @@
"sass": "1.49.9",
"sinon": "13.0.1",
"sinon-chrome": "3.0.1",
"ts-loader": "9.5.0",
"webpack-stream": "7.0.0",
"yargs": "17.3.1"
},
Expand Down