Skip to content

Commit 17e9e7d

Browse files
committed
chore: change types workflow
1 parent eadbd12 commit 17e9e7d

33 files changed

+559
-135
lines changed

.changeset/hot-kiwis-allow.md

+11
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
---
2+
'@import-maps/resolve': patch
3+
'@mdjs/core': patch
4+
'polyfills-loader': patch
5+
'@open-wc/scoped-elements': patch
6+
'@open-wc/semantic-dom-diff': patch
7+
'@open-wc/testing': patch
8+
'@open-wc/testing-helpers': patch
9+
---
10+
11+
Change type distribution workflow

.github/workflows/release.yml

+1-1
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ jobs:
4040
run: yarn --frozen-lockfile
4141

4242
- name: Build types
43-
run: yarn build:types
43+
run: yarn types
4444

4545
- name: Create Release Pull Request or Publish to npm
4646
id: changesets

.gitignore

+4
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,10 @@
88
## code coverage folders
99
coverage/
1010

11+
## generated types
12+
packages/*/types
13+
tsconfig.tsbuildinfo
14+
1115
## npm
1216
node_modules
1317
!packages/es-dev-server/test/**/node_modules

package.json

+11-5
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@
33
"private": true,
44
"license": "MIT",
55
"scripts": {
6-
"build:types": "tsc -p tsconfig.build.types.json",
76
"codelabs:build": "node ./packages/codelabs/build-codelabs.js",
87
"docs:build": "rimraf _site && node cli-build.js",
98
"docs:serve-build": "node packages/es-dev-server/dist/cli.js -o docs/",
@@ -14,17 +13,23 @@
1413
"lint": "run-p lint:*",
1514
"lint:eslint": "eslint --ext .js,.html .",
1615
"lint:prettier": "prettier \"**/*.{js,md}\" \"**/package.json\" --check",
17-
"lint:types": "tsc",
16+
"lint:types": "npm run types",
1817
"lint:versions": "node ./scripts/lint-versions.js",
19-
"postinstall": "patch-package",
18+
"postinstall": "patch-package && npm run setup",
2019
"release": "changeset publish && yarn format",
20+
"setup": "npm run setup:ts-configs",
21+
"setup:ts-configs": "node scripts/generate-ts-configs.mjs",
2122
"site:build": "npm run docs:build && node scripts/workspaces-scripts-bin.mjs site:build",
2223
"site:start": "npm run docs:start",
2324
"start": "npm run docs:start",
2425
"test": "yarn test:web && yarn test:node",
2526
"test:node": "mocha \"packages/*/test-node/**/*.test.{ts,js,mjs,cjs}\" --exit --retries 3",
2627
"test:node:watch": "mocha \"packages/*/test-node/**/*.test.{ts,js,mjs,cjs}\" --watch",
2728
"test:web": "web-test-runner",
29+
"types": "run-s types:clear types:copy types:build",
30+
"types:build": "tsc --build",
31+
"types:clear": "rimraf packages/*/types/",
32+
"types:copy": "node scripts/workspaces-scripts-bin.mjs types:copy",
2833
"update-dependency": "node scripts/update-dependency.js"
2934
},
3035
"dependencies": {
@@ -41,11 +46,13 @@
4146
"@types/eslint": "^7.2.4",
4247
"@types/estree": "^0.0.45",
4348
"@types/parse5-htmlparser2-tree-adapter": "^5.0.1",
49+
"@web/dev-server": "^0.0.15",
4450
"@web/test-runner": "^0.9.5",
4551
"@web/test-runner-playwright": "^0.6.4",
4652
"babel-eslint": "^10.0.3",
4753
"chai": "^4.2.0",
4854
"concurrently": "^5.2.0",
55+
"copyfiles": "^2.4.0",
4956
"core-js": "2.6.10",
5057
"eslint": "^7.6.0",
5158
"eslint-config-airbnb-base": "^14.0.0",
@@ -68,8 +75,7 @@
6875
"rollup": "^2.7.2",
6976
"rollup-plugin-copy": "^3.3.0",
7077
"sinon": "^7.4.1",
71-
"typescript": "~4.0.3",
72-
"webpack-merge": "^4.1.5"
78+
"typescript": "~4.0.3"
7379
},
7480
"resolutions": {
7581
"@types/estree": "0.0.45"

packages/building-rollup/test-node/integration.test.js

+12-13
Original file line numberDiff line numberDiff line change
@@ -5,39 +5,38 @@ const path = require('path');
55
const fs = require('fs');
66
const rimraf = require('rimraf');
77
const { rollup } = require('rollup');
8-
const { startServer, createConfig } = require('es-dev-server');
8+
const { startDevServer } = require('@web/dev-server');
99

1010
const rootDir = path.resolve(__dirname, '..', 'dist');
1111

1212
describe('integration tests', () => {
1313
let server;
14-
let serverConfig;
1514
/** @type {import('puppeteer').Browser} */
1615
let browser;
1716

1817
before(async () => {
19-
serverConfig = createConfig({
20-
port: 8081,
21-
rootDir,
18+
server = await startDevServer({
19+
config: {
20+
port: 8081,
21+
rootDir,
22+
},
23+
readCliArgs: false,
24+
readFileConfig: false,
25+
logStartMessage: false,
26+
clearTerminalOnReload: false,
2227
});
23-
24-
({ server } = await startServer(serverConfig));
2528
browser = await puppeteer.launch();
2629
rimraf.sync(rootDir);
2730
});
2831

2932
after(async () => {
3033
await browser.close();
31-
await new Promise(resolve =>
32-
server.close(() => {
33-
resolve();
34-
}),
35-
);
34+
await server.stop();
3635
});
3736

3837
['js/rollup.spa.config.js', 'js/rollup.spa-nomodule.config.js'].forEach(testCase => {
3938
describe(`testcase ${testCase}`, function describe() {
40-
this.timeout(20000);
39+
this.timeout(30000);
4140
let page;
4241

4342
before(async () => {

packages/building-rollup/test-node/mpa-integration.test.js

+12-13
Original file line numberDiff line numberDiff line change
@@ -5,38 +5,37 @@ const path = require('path');
55
const fs = require('fs');
66
const rimraf = require('rimraf');
77
const { rollup } = require('rollup');
8-
const { startServer, createConfig } = require('es-dev-server');
8+
const { startDevServer } = require('@web/dev-server');
99

1010
const rootDir = path.resolve(__dirname, '..', 'dist');
1111

1212
describe('integration tests', () => {
1313
let server;
14-
let serverConfig;
1514
/** @type {import('puppeteer').Browser} */
1615
let browser;
1716

1817
before(async () => {
19-
serverConfig = createConfig({
20-
port: 8081,
21-
rootDir,
18+
server = await startDevServer({
19+
config: {
20+
port: 8081,
21+
rootDir,
22+
},
23+
readCliArgs: false,
24+
readFileConfig: false,
25+
logStartMessage: false,
26+
clearTerminalOnReload: false,
2227
});
23-
24-
({ server } = await startServer(serverConfig));
2528
browser = await puppeteer.launch();
2629
rimraf.sync(rootDir);
2730
});
2831

2932
after(async () => {
3033
await browser.close();
31-
await new Promise(resolve =>
32-
server.close(() => {
33-
resolve();
34-
}),
35-
);
34+
await server.stop();
3635
});
3736

3837
describe(`Mpa Config`, function describe() {
39-
this.timeout(20000);
38+
this.timeout(30000);
4039
let page;
4140

4241
before(async () => {

packages/import-maps-resolve/package.json

+6-3
Original file line numberDiff line numberDiff line change
@@ -17,15 +17,18 @@
1717
"scripts": {
1818
"prepublishOnly": "../../scripts/insert-header.js",
1919
"test": "npm run test:node",
20-
"test:node": "mocha test/run-tests.js"
20+
"test:node": "mocha test/run-tests.js",
21+
"types:copy": "copyfiles \"./src/**/*.d.ts\" \"./*.d.ts\" types"
2122
},
2223
"files": [
2324
"*.d.ts",
2425
"*.js",
25-
"src"
26+
"src",
27+
"types"
2628
],
2729
"keywords": [
2830
"import-map",
2931
"import-maps"
30-
]
32+
],
33+
"types": "types/index.d.ts"
3134
}
+21-4
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,23 @@
1+
// Don't edit this file directly. It is generated by /scripts/update-package-configs.ts
2+
13
{
2-
"extends": "../../tsconfig.json",
4+
"extends": "../../tsconfig.node-base.json",
35
"compilerOptions": {
4-
"strict": true
5-
}
6-
}
6+
"module": "commonjs",
7+
"outDir": "./types",
8+
"rootDir": ".",
9+
"composite": true,
10+
"allowJs": true,
11+
"checkJs": true,
12+
"emitDeclarationOnly": true
13+
},
14+
"references": [],
15+
"include": [
16+
"src",
17+
"*.js"
18+
],
19+
"exclude": [
20+
"dist",
21+
"types"
22+
]
23+
}

packages/mdjs/index.d.ts

-7
This file was deleted.

packages/mdjs/package.json

+3-2
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,8 @@
2121
"start:stories": "node ../es-dev-server/dist/cli.js -c demo/stories/server.js --root-dir ../../",
2222
"test": "npm run test:node",
2323
"test:node": "mocha test-node",
24-
"test:watch": "mocha test-node --watch"
24+
"test:watch": "mocha test-node --watch",
25+
"types:copy": "copyfiles -f \"./types-global/**/*.d.ts\" types"
2526
},
2627
"files": [
2728
"*.d.ts",
@@ -61,5 +62,5 @@
6162
"remark-slug": "^5.1.2",
6263
"remark-stringify": "^7.0.4"
6364
},
64-
"types": "index.d.ts"
65+
"types": "./types/index.d.ts"
6566
}
File renamed without changes.

packages/mdjs/tsconfig.json

+23
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
// Don't edit this file directly. It is generated by /scripts/update-package-configs.ts
2+
3+
{
4+
"extends": "../../tsconfig.node-base.json",
5+
"compilerOptions": {
6+
"module": "commonjs",
7+
"outDir": "./types",
8+
"rootDir": ".",
9+
"composite": true,
10+
"allowJs": true,
11+
"checkJs": true,
12+
"emitDeclarationOnly": true
13+
},
14+
"references": [],
15+
"include": [
16+
"src",
17+
"*.js"
18+
],
19+
"exclude": [
20+
"dist",
21+
"types"
22+
]
23+
}

packages/polyfills-loader/package.json

+4-2
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,8 @@
2222
"test": "npm run test:node",
2323
"test:node": "mocha test/**/*.test.js test/**/*.test.js",
2424
"test:update-snapshots": "mocha test/**/*.test.js test/**/*.test.js --update-snapshots",
25-
"test:watch": "mocha test/**/*.test.js test/**/*.test.js --watch"
25+
"test:watch": "mocha test/**/*.test.js test/**/*.test.js --watch",
26+
"types:copy": "copyfiles \"./src/**/*.d.ts\" \"./*.d.ts\" types"
2627
},
2728
"files": [
2829
"index.d.ts",
@@ -50,5 +51,6 @@
5051
"@types/babel__core": "^7.1.3",
5152
"@types/parse5": "^5.0.2",
5253
"@types/valid-url": "^1.0.2"
53-
}
54+
},
55+
"types": "types/index.d.ts"
5456
}

packages/polyfills-loader/src/inject-polyfills-loader.js

+3
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,9 @@ const {
1111
insertAfter,
1212
append,
1313
cloneNode,
14+
// @ts-ignore
1415
} = require('@open-wc/building-utils/dom5-fork');
16+
// @ts-ignore
1517
const { createScript, createElement, findImportMapScripts } = require('@open-wc/building-utils');
1618
const { createPolyfillsLoader } = require('./create-polyfills-loader');
1719
const { hasFileOfType, fileTypes } = require('./utils');
@@ -70,6 +72,7 @@ function injectLoaderScript(bodyAst, polyfillsLoader) {
7072
* @param {PolyfillsLoaderConfig} cfg
7173
*/
7274
function injectPrefetchLinks(headAst, cfg) {
75+
// @ts-ignore
7376
for (const file of cfg.modern.files) {
7477
const { path } = file;
7578
const href = path.startsWith('.') || path.startsWith('/') ? path : `./${path}`;

packages/polyfills-loader/src/utils.js

+2
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
/** @typedef {import('./types').FileType} FileType */
44
/** @typedef {import('./types').PolyfillsLoaderConfig} PolyfillsLoaderConfig */
55

6+
// @ts-ignore
67
const { getAttribute } = require('@open-wc/building-utils/dom5-fork');
78
const crypto = require('crypto');
89

@@ -54,6 +55,7 @@ function getScriptFileType(script) {
5455
*/
5556
function hasFileOfType(cfg, type) {
5657
return (
58+
// @ts-ignore
5759
cfg.modern.files.some(f => f.type === type) ||
5860
(cfg.legacy && cfg.legacy.some(e => e.files.some(f => f.type === type)))
5961
);
+21-4
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,23 @@
1+
// Don't edit this file directly. It is generated by /scripts/update-package-configs.ts
2+
13
{
2-
"extends": "../../tsconfig.json",
4+
"extends": "../../tsconfig.node-base.json",
35
"compilerOptions": {
4-
"strict": true
5-
}
6-
}
6+
"module": "commonjs",
7+
"outDir": "./types",
8+
"rootDir": ".",
9+
"composite": true,
10+
"allowJs": true,
11+
"checkJs": true,
12+
"emitDeclarationOnly": true
13+
},
14+
"references": [],
15+
"include": [
16+
"src",
17+
"*.js"
18+
],
19+
"exclude": [
20+
"dist",
21+
"types"
22+
]
23+
}

packages/scoped-elements/package.json

+3-1
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,8 @@
2424
"start:no-scope": "es-dev-server -c demo/no-scope/server.js",
2525
"start:with-scope": "es-dev-server -c demo/with-scope/server.js",
2626
"test": "cd ../../ && yarn test:browser --grep \"packages/scoped-elements/test/*.test.js\"",
27-
"test:watch": "cd ../../ && yarn test:browser:watch --grep \"packages/scoped-elements/test/*.test.js\""
27+
"test:watch": "cd ../../ && yarn test:browser:watch --grep \"packages/scoped-elements/test/*.test.js\"",
28+
"types:copy": "copyfiles \"./src/**/*.d.ts\" \"./*.d.ts\" types"
2829
},
2930
"files": [
3031
"*.d.ts",
@@ -42,5 +43,6 @@
4243
"@open-wc/dedupe-mixin": "^1.3.0",
4344
"lit-html": "^1.0.0"
4445
},
46+
"types": "types/index.d.ts",
4547
"sideEffects": false
4648
}

0 commit comments

Comments
 (0)