-
Notifications
You must be signed in to change notification settings - Fork 10
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
basic TS support and caveats for other formats
- Loading branch information
1 parent
46e06fb
commit 55a6dd2
Showing
7 changed files
with
56 additions
and
10 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
35 changes: 35 additions & 0 deletions
35
packages/plugin-css-modules/test/cases/loaders-build.prerender/greenwood.config.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,8 +1,43 @@ | ||
import fs from 'fs/promises'; | ||
import { greenwoodPluginCssModules } from '../../../src/index.js'; | ||
import { transform } from 'sucrase'; | ||
|
||
class NaiveTsResource { | ||
constructor(compilation, options) { | ||
this.compilation = compilation; | ||
this.options = options; | ||
|
||
this.extensions = ['ts']; | ||
this.contentType = 'text/javascript'; | ||
} | ||
|
||
async shouldServe(url) { | ||
return url.pathname.split('.').pop() === this.extensions[0]; | ||
} | ||
|
||
async serve(url) { | ||
const scriptContents = await fs.readFile(url, 'utf-8'); | ||
const result = transform(scriptContents, { | ||
transforms: ['typescript', 'jsx'], | ||
jsxRuntime: 'preserve' | ||
}); | ||
|
||
return new Response(result.code, { | ||
headers: new Headers({ | ||
'Content-Type': this.contentType | ||
}) | ||
}); | ||
} | ||
} | ||
|
||
export default { | ||
prerender: true, | ||
plugins: [ | ||
{ | ||
type: 'resource', | ||
name: 'plugin-naive-ts', | ||
provider: (compilation, options) => new NaiveTsResource(compilation, options) | ||
}, | ||
greenwoodPluginCssModules() | ||
] | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
2 changes: 1 addition & 1 deletion
2
...ges/plugin-css-modules/test/cases/loaders-build.prerender/src/components/header/header.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
2 changes: 2 additions & 0 deletions
2
...ild.prerender/src/components/logo/logo.js → ...ild.prerender/src/components/logo/logo.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters