Skip to content

Commit

Permalink
merge user and default options and better document pages support with…
Browse files Browse the repository at this point in the history
… custom imports
  • Loading branch information
thescientist13 committed Nov 8, 2024
1 parent 1ce74c7 commit af6040a
Show file tree
Hide file tree
Showing 4 changed files with 15 additions and 8 deletions.
6 changes: 4 additions & 2 deletions packages/plugin-typescript/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -101,9 +101,11 @@ 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.

### 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).

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

0 comments on commit af6040a

Please sign in to comment.