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

bug/issue 1295 preserve default TypeScript plugin options when merging additional user provided options #1299

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
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
8 changes: 5 additions & 3 deletions packages/plugin-typescript/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -99,11 +99,13 @@ If you would like to extend / override these options:
};
```

This will then process your JavaScript with TypeScript with the additional configuration settings you provide. This also allows you to configure the rest of _tsconfig.json_ to support your IDE and local development environment settings.
This will then process your JavaScript with TypeScript with the additional configuration settings you provide. This also allows you to configure the rest of your _tsconfig.json_ to support your project specific IDE and local development environment settings.

### Custom Pages
### Pages

By default, this plugin extends TypeScript support to processing SSR pages and API routes. If you would like to _disable_ this, set the `servePage` option to `false`
By default, this plugin extends TypeScript support for processing [SSR pages](https://www.greenwoodjs.dev/docs/pages/server-rendering/) and [API routes](https://www.greenwoodjs.dev/docs/pages/api-routes/). For this feature, you will need to enable [custom imports](https://www.greenwoodjs.dev/docs/pages/server-rendering/#custom-imports).
Copy link
Member Author

Choose a reason for hiding this comment

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


If you would like to _disable_ this feature completely, set the `servePage` option to `false`:

```js
import { greenwoodPluginTypeScript } from '@greenwood/plugin-typescript';
Expand Down
7 changes: 5 additions & 2 deletions packages/plugin-typescript/src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -55,11 +55,14 @@ class TypeScriptResource extends ResourceInterface {
}
}

const greenwoodPluginTypeScript = (options = { servePage: 'dynamic' }) => {
const greenwoodPluginTypeScript = (options = {}) => {
return [{
type: 'resource',
name: 'plugin-import-typescript:resource',
provider: (compilation) => new TypeScriptResource(compilation, options)
provider: (compilation) => new TypeScriptResource(compilation, {
servePage: 'dynamic',
...options
})
}];
};

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,10 @@ import { greenwoodPluginTypeScript } from '../../../src/index.js';
export default {
prerender: true,
plugins: [
greenwoodPluginTypeScript()
greenwoodPluginTypeScript({
// make sure we don't lose default value of servePage
// https://github.com/ProjectEvergreen/greenwood/issues/1295
foo: 'bar'
})
]
};
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,7 @@
* {
* prerender: true,
* plugins: [
* greenwoodPluginTypeScript({
* servePage: 'dynamic'
* })
* greenwoodPluginTypeScript()
* ]
* }
*
Expand Down
Loading