Skip to content

Commit d302b45

Browse files
committed
fixup! Rewrite the plugin to handle general static assets.
1 parent a19cbe5 commit d302b45

46 files changed

Lines changed: 271 additions & 139 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

build-tests/heft-node-everything-test/config/heft.json

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,18 @@
1616
"cleanFiles": [{ "includeGlobs": ["dist", "lib-commonjs", "lib", "lib-esm", "lib-esnext", "lib-umd"] }],
1717

1818
"tasksByName": {
19+
"text-typings": {
20+
"taskPlugin": {
21+
"pluginPackage": "@rushstack/heft-static-asset-typings-plugin",
22+
"pluginName": "text-assets-plugin",
23+
"options": {
24+
"cjsOutputFolders": ["lib-commonjs"],
25+
"esmOutputFolders": ["lib-esm"]
26+
}
27+
}
28+
},
1929
"typescript": {
30+
"taskDependencies": ["text-typings"],
2031
"taskPlugin": {
2132
"pluginPackage": "@rushstack/heft-typescript-plugin"
2233
}

build-tests/heft-node-everything-test/config/jest.config.json

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,10 @@
11
{
22
"extends": "@rushstack/heft-jest-plugin/includes/jest-shared.config.json",
33

4+
// The project outputs to lib-commonjs, not lib
5+
"roots": ["<rootDir>/lib-commonjs"],
6+
"testMatch": ["<rootDir>/lib-commonjs/**/*.test.{cjs,js}"],
7+
48
// Enable code coverage for Jest
59
"collectCoverage": true,
610
"coverageDirectory": "<rootDir>/coverage",

build-tests/heft-node-everything-test/config/rush-project.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
"operationSettings": [
55
{
66
"operationName": "_phase:build",
7-
"outputFolderNames": ["dist", "lib-commonjs", "lib-esm", "lib-umd", "lib-dts"]
7+
"outputFolderNames": ["dist", "lib-commonjs", "lib-esm", "lib-umd", "lib-dts", "temp/text-typings"]
88
},
99
{
1010
"operationName": "_phase:test",
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
{
2+
"fileExtensions": [".html"],
3+
"generatedTsFolder": "temp/text-typings"
4+
}

build-tests/heft-node-everything-test/etc/heft-node-everything-test.api.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,9 @@
44
55
```ts
66

7+
// @public
8+
export const templateContent: string;
9+
710
// @public (undocumented)
811
export class TestClass {
912
}

build-tests/heft-node-everything-test/package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@
1616
"@microsoft/api-extractor": "workspace:*",
1717
"@rushstack/heft": "workspace:*",
1818
"@rushstack/heft-api-extractor-plugin": "workspace:*",
19+
"@rushstack/heft-static-asset-typings-plugin": "workspace:*",
1920
"@rushstack/heft-jest-plugin": "workspace:*",
2021
"@rushstack/heft-lint-plugin": "workspace:*",
2122
"@rushstack/heft-typescript-plugin": "workspace:*",
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
<!doctype html>
2+
<html>
3+
<head>
4+
<title>Example Template</title>
5+
</head>
6+
<body>
7+
<p>Hello, world!</p>
8+
</body>
9+
</html>

build-tests/heft-node-everything-test/src/index.ts

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,14 @@
11
// Copyright (c) Microsoft Corporation. All rights reserved. Licensed under the MIT license.
22
// See LICENSE in the project root for license information.
33

4+
import exampleTemplate from './exampleTemplate.html';
5+
6+
/**
7+
* The content of exampleTemplate.html, imported as a text asset.
8+
* @public
9+
*/
10+
export const templateContent: string = exampleTemplate;
11+
412
/**
513
* @public
614
*/

build-tests/heft-node-everything-test/src/test/ExampleTest.test.ts

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
11
// Copyright (c) Microsoft Corporation. All rights reserved. Licensed under the MIT license.
22
// See LICENSE in the project root for license information.
33

4+
import { templateContent } from '../index';
5+
46
interface IInterface {
57
element: string;
68
}
@@ -20,4 +22,10 @@ describe('Example Test', () => {
2022
};
2123
expect(interfaceInstance).toBeTruthy();
2224
});
25+
26+
it('Correctly imports text assets', () => {
27+
expect(typeof templateContent).toBe('string');
28+
expect(templateContent).toContain('<title>Example Template</title>');
29+
expect(templateContent).toContain('Hello, world!');
30+
});
2331
});

build-tests/heft-node-everything-test/tsconfig.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
"outDir": "lib-commonjs",
66
"declarationDir": "lib-dts",
77
"rootDir": "src",
8+
"rootDirs": ["src", "temp/text-typings"],
89

910
"forceConsistentCasingInFileNames": true,
1011
"jsx": "react",

0 commit comments

Comments
 (0)