Skip to content

Commit

Permalink
Merge pull request #770 from wheresrhys/rhys/toolchain-import-tests
Browse files Browse the repository at this point in the history
Rhys/toolchain import tests
  • Loading branch information
wheresrhys authored Aug 2, 2024
2 parents 2768ea6 + cd88c33 commit 9dd5a09
Show file tree
Hide file tree
Showing 10 changed files with 223 additions and 9 deletions.
19 changes: 15 additions & 4 deletions .circleci/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -91,6 +91,14 @@ jobs:
- *workspace
- run: npm run build
- run: npm run test:jest
import-compat:
<<: *nodelts
steps:
- *workspace
- run: npm run compat:ts:cjs -w import-compat
- run: npm run compat:js:cjs -w import-compat
- run: npm run compat:ts:esm -w import-compat
- run: npm run compat:js:esm -w import-compat
# chrome:
# <<: *browsers
# steps:
Expand Down Expand Up @@ -133,12 +141,10 @@ workflows:
<<: *triggerable-by-tag
requires:
- checkout_code
# could be parallel with build, lint, and unit but it's a slow job
# And circlecifree tier only has 3 concurrent jobs, so overall faster
# to defer
- typelint:
<<: *triggerable-by-tag
<<: *run-after-first-jobs
requires:
- checkout_code
- nodefetch3:
<<: *triggerable-by-tag
<<: *run-after-first-jobs
Expand All @@ -148,6 +154,10 @@ workflows:
- jest:
<<: *triggerable-by-tag
<<: *run-after-first-jobs
- import-compat:
<<: *triggerable-by-tag
requires:
- build
# - chrome:
# <<: *triggerable-by-tag
# <<: *run-after-first-jobs
Expand All @@ -160,6 +170,7 @@ workflows:
# - chrome
# - firefox
- build
- import-compat
- typelint
- commonjs
- jest
Expand Down
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -13,3 +13,5 @@ coverage/
# built files
/docs/fetch-mock/dist/
/packages/**/dist

import-compat/ts-*.js
5 changes: 5 additions & 0 deletions import-compat/js-cjs.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
const fetchMockCore = require('@fetch-mock/core').default;
fetchMockCore.route('http://example.com', 200);

const fetchMock = require('fetch-mock').default;
fetchMock.mock('http://example.com', 200);
5 changes: 5 additions & 0 deletions import-compat/js-esm.mjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
import fetchMockCore from "@fetch-mock/core";
fetchMockCore.route("http://example.com", 200);

import fetchMock from "fetch-mock";
fetchMock.mock("http://example.com", 200);
10 changes: 10 additions & 0 deletions import-compat/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
{
"name": "fetch-mock-compat-tests",
"version": "1.0.0",
"scripts": {
"compat:ts:esm": "tsc ts-esm.ts --target esnext --moduleResolution nodenext --module nodenext && node ts-esm.js",
"compat:ts:cjs": "tsc ts-cjs.ts --target esnext --moduleResolution nodenext --module nodenext && node ts-cjs.js",
"compat:js:esm": "node js-esm.mjs",
"compat:js:cjs": "node js-cjs.js"
}
}
5 changes: 5 additions & 0 deletions import-compat/ts-cjs.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
const fetchMockCore = require("@fetch-mock/core").default;
fetchMockCore.route("http://example.com", 200);

const fetchMock = require("fetch-mock").default;
fetchMock.mock("http://example.com", 200);
5 changes: 5 additions & 0 deletions import-compat/ts-esm.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
import fetchMockCore from "@fetch-mock/core";
fetchMockCore.route("http://example.com", 200);

import fetchMock from "fetch-mock";
fetchMock.mock("http://example.com", 200);
171 changes: 170 additions & 1 deletion package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

9 changes: 5 additions & 4 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,8 @@
},
"workspaces": [
"packages/*",
"docs"
"docs",
"import-compat"
],
"scripts": {
"lint:staged": "eslint --cache --fix --ext .js,.cjs",
Expand All @@ -43,6 +44,8 @@
"@commitlint/config-conventional": "^19.2.2",
"@rollup/plugin-commonjs": "^25.0.7",
"@rollup/plugin-node-resolve": "^15.2.3",
"@types/events": "^3.0.3",
"@types/globrex": "^0.1.4",
"@types/node": "^20.14.10",
"@vitest/browser": "^1.1.0",
"@vitest/coverage-istanbul": "^1.1.0",
Expand All @@ -65,8 +68,6 @@
"typescript": "^5.5.3",
"v8": "^0.1.0",
"vitest": "^1.1.0",
"@types/events": "^3.0.3",
"@types/globrex": "^0.1.4",
"webdriverio": "^8.27.0"
},
"volta": {
Expand All @@ -79,7 +80,7 @@
"packages/**/*.js": [
"npm run types:check"
],
"**/*.md":[
"**/*.md": [
"npm run prettier"
]
}
Expand Down
1 change: 1 addition & 0 deletions shared-rollup.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ export default {
dir: './dist',
entryFileNames: 'commonjs.js',
format: 'commonjs',
// exports: 'named',
},
plugins: [
nodeResolve({ preferBuiltins: false }),
Expand Down

0 comments on commit 9dd5a09

Please sign in to comment.