Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use Vite (again) #47

Merged
merged 28 commits into from
Oct 13, 2022
Merged
Show file tree
Hide file tree
Changes from 27 commits
Commits
Show all changes
28 commits
Select commit Hold shift + click to select a range
7ac09ea
WIP
mrm007 Sep 27, 2022
e5db6f1
WIP - don't forget to update crackel2 snapshots
mrm007 Sep 27, 2022
1078944
bump vite to latest (with build+ssr patch)
mrm007 Oct 6, 2022
ecd6cd5
sync `@crackle/core` dependencies with Vite's
mrm007 Oct 6, 2022
7536a35
bump Braid snapshot
mrm007 Oct 6, 2022
4a945ba
fix tests & lint errors
mrm007 Oct 6, 2022
bdde480
bump Braid snapshot (with .mjs)
mrm007 Oct 6, 2022
8f7057a
more comprehensive fixtures
mrm007 Oct 6, 2022
6cc8312
tweak CI script
mrm007 Oct 6, 2022
7021bea
solve the .mjs problem
mrm007 Oct 6, 2022
890f7d4
replace `resolve-from` with our own
mrm007 Oct 7, 2022
cc64dd2
tidy up externals plugin
mrm007 Oct 7, 2022
8901537
remove unused dependencies
mrm007 Oct 7, 2022
8924531
remove Vite patch, update Vitest
mrm007 Oct 7, 2022
2854de5
add a changeset
mrm007 Oct 7, 2022
0724b6f
create an entry for esbuild plugins
mrm007 Oct 7, 2022
34af623
tweak extension replacement
mrm007 Oct 7, 2022
a983ab5
Merge remote-tracking branch 'origin/master' into vite-lib-mode
mrm007 Oct 7, 2022
1e58005
fix Playwright tests and add a comment about `crackle start`
mrm007 Oct 7, 2022
683c714
SHAMEFULLY HOIST so things don't break
mrm007 Oct 7, 2022
a687cd7
pin Playwright to a version which doesn't break with dynamic imports
mrm007 Oct 7, 2022
bccac26
remove Vite workarounds
mrm007 Oct 7, 2022
c753774
bump Braid snapshot (with .mjs)
mrm007 Oct 7, 2022
fda2caa
formatting
mrm007 Oct 9, 2022
613fde0
use a more precise dependency specifier
mrm007 Oct 10, 2022
5110329
update changeset
mrm007 Oct 11, 2022
5a8af97
Merge remote-tracking branch 'origin/master' into vite-lib-mode
mrm007 Oct 12, 2022
79b70ea
code review feedback
mrm007 Oct 13, 2022
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
5 changes: 5 additions & 0 deletions .changeset/blue-rings-lay.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'@crackle/core': minor
---

Use `.mjs` file extension for ESM bundles. Please read the [pull request description](https://github.com/seek-oss/crackle/pull/47) for more details.
2 changes: 1 addition & 1 deletion .github/workflows/validate.yml
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ jobs:
run: pnpm build

- name: Set up fixtures
run: pnpm fixtures package
run: pnpm fixtures --aggregate-output package

- name: Lint
run: pnpm lint
Expand Down
3 changes: 2 additions & 1 deletion .npmrc
Original file line number Diff line number Diff line change
@@ -1 +1,2 @@
strict-peer-dependencies=false
strict-peer-dependencies=false
shamefully-hoist=true
2 changes: 1 addition & 1 deletion fixtures/braid-site/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
"@crackle-fixtures/library-with-docs": "workspace:*",
"@crackle/router": "workspace:*",
"@vanilla-extract/css": "^1.9.1",
"braid-design-system": "0.0.0-crackel2-20220919072731",
"braid-design-system": "0.0.0-crackel2-20221007054115",
"react": "17.0.2",
"react-dom": "^17.0.2"
},
Expand Down
2 changes: 1 addition & 1 deletion fixtures/braid-site/src/App.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import {
Heading,
Stack,
} from 'braid-design-system';
import apac from 'braid-design-system/apacTheme';
import apac from 'braid-design-system/themes/apac';
import React from 'react';

const App: AppShell = ({ children }) => (
Expand Down
8 changes: 5 additions & 3 deletions fixtures/library-with-docs/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,12 +8,12 @@
"./package.json": "./package.json",
".": {
"types": "./dist/index.cjs.d.ts",
"import": "./dist/index.js",
"import": "./dist/index.mjs",
"require": "./dist/index.cjs"
}
},
"main": "./dist/index.cjs",
"module": "./dist/index.js",
"module": "./dist/index.mjs",
"files": [
"/dist"
],
Expand All @@ -27,14 +27,16 @@
"dependencies": {
"@crackle/router": "workspace:*",
"@vanilla-extract/css": "^1.9.1",
"braid-design-system": "0.0.0-crackel2-20220919072731",
"autosuggest-highlight": "^3.3.4",
"braid-design-system": "0.0.0-crackel2-20221007054115",
"lodash": "^4.17.21",
"react": "17.0.2",
"react-dom": "^17.0.2"
},
"devDependencies": {
"@crackle/cli": "workspace:*",
"@crackle/core": "workspace:*",
"@types/autosuggest-highlight": "^3.2.0",
"@types/lodash": "^4.14.186",
"@types/react": "^17",
"@types/react-dom": "^17"
Expand Down
2 changes: 1 addition & 1 deletion fixtures/library-with-docs/src/App.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import {
makeLinkComponent,
Stack,
} from 'braid-design-system';
import apac from 'braid-design-system/apacTheme';
import apac from 'braid-design-system/themes/apac';
import React from 'react';

const CustomLink = makeLinkComponent(({ href, ...restProps }, ref) =>
Expand Down
2 changes: 2 additions & 0 deletions fixtures/library-with-docs/src/index.ts
Original file line number Diff line number Diff line change
@@ -1 +1,3 @@
export { JobSummary } from './components/JobSummary/JobSummary';

export { default as parse } from 'autosuggest-highlight/parse';
12 changes: 6 additions & 6 deletions fixtures/multi-entry-library/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,27 +8,27 @@
"./package.json": "./package.json",
".": {
"types": "./dist/index.cjs.d.ts",
"import": "./dist/index.js",
"import": "./dist/index.mjs",
"require": "./dist/index.cjs"
},
"./components": {
"types": "./components/dist/index.cjs.d.ts",
"import": "./components/dist/index.js",
"import": "./components/dist/index.mjs",
"require": "./components/dist/index.cjs"
},
"./extras": {
"types": "./extras/dist/index.cjs.d.ts",
"import": "./extras/dist/index.js",
"import": "./extras/dist/index.mjs",
"require": "./extras/dist/index.cjs"
},
"./themes/apac": {
"types": "./themes/apac/dist/index.cjs.d.ts",
"import": "./themes/apac/dist/index.js",
"import": "./themes/apac/dist/index.mjs",
"require": "./themes/apac/dist/index.cjs"
}
},
"main": "./dist/index.cjs",
"module": "./dist/index.js",
"module": "./dist/index.mjs",
"files": [
"/components",
"/dist",
Expand All @@ -43,7 +43,7 @@
},
"dependencies": {
"@crackle/router": "workspace:*",
"braid-design-system": "0.0.0-crackel2-20220919072731",
"braid-design-system": "0.0.0-crackel2-20221007054115",
"react": "17.0.2",
"react-dom": "^17.0.2"
},
Expand Down
6 changes: 3 additions & 3 deletions fixtures/single-entry-library/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,12 +8,12 @@
"./package.json": "./package.json",
".": {
"types": "./dist/index.cjs.d.ts",
"import": "./dist/index.js",
"import": "./dist/index.mjs",
"require": "./dist/index.cjs"
}
},
"main": "./dist/index.cjs",
"module": "./dist/index.js",
"module": "./dist/index.mjs",
"files": [
"/dist"
],
Expand All @@ -26,7 +26,7 @@
"dependencies": {
"@crackle-fixtures/multi-entry-library": "workspace:*",
"@vanilla-extract/css": "^1.9.1",
"braid-design-system": "0.0.0-crackel2-20220919072731",
"braid-design-system": "0.0.0-crackel2-20221007054115",
"react": "17.0.2",
"react-dom": "^17.0.2"
},
Expand Down
9 changes: 5 additions & 4 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"name": "project-crackle",
"name": "crackle",
"version": "0.1.0",
"private": true,
"scripts": {
Expand All @@ -8,8 +8,9 @@
"build": "preconstruct build",
"watch": "preconstruct watch",
"fixtures": "pnpm --recursive --filter='@crackle-fixtures/*'",
"lint": "tsc --noEmit && eslint . && prettier --check .",
"format": "eslint --fix . && prettier --write .",
"lint": "tsc --noEmit && eslint . && prettier --check .",
"sync-dependencies": "pnpm --recursive sync-dependencies",
"test": "pnpm test:vitest --run && pnpm test:playwright",
"test:vitest": "vitest",
"test:playwright": "playwright test",
Expand All @@ -21,7 +22,7 @@
"@babel/preset-react": "^7.14.5",
"@babel/preset-typescript": "^7.15.0",
"@changesets/cli": "^2.24.4",
"@playwright/test": "^1.14.1",
"@playwright/test": "1.22.2",
askoufis marked this conversation as resolved.
Show resolved Hide resolved
"@preconstruct/cli": "^2.2.1",
"prettier": "^2.7.1",
"typescript": "~4.7.4"
Expand All @@ -47,6 +48,6 @@
"eslint-config-seek": "^9.0.0",
"fixturez": "^1.1.0",
"snapshot-diff": "^0.9.0",
"vitest": "^0.21.1"
"vitest": "^0.23.4"
}
}
23 changes: 10 additions & 13 deletions packages/core/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,9 @@
"/serve",
"/start"
],
"scripts": {
"sync-dependencies": "sync-dependencies --source vite"
},
"preconstruct": {
"entrypoints": [
"build.ts",
Expand All @@ -83,52 +86,46 @@
"@babel/plugin-syntax-typescript": "^7.14.5",
"@crackle/babel-plugin-remove-exports": "0.1.0",
"@crackle/router": "0.2.0",
"@rollup/plugin-commonjs": "^22.0.2",
"@rollup/plugin-node-resolve": "^13.3.0",
"@vanilla-extract/babel-plugin": "^1.1.2",
"@vanilla-extract/css": "^1.9.1",
"@vanilla-extract/integration": "^6.0.0",
"@vanilla-extract/vite-plugin": "^3.6.1",
"@vitejs/plugin-react": "^2.1.0",
"builtin-modules": "^3.2.0",
"chalk": "^4.0.0",
"ensure-gitignore": "^1.2.0",
"esbuild": ">= 0.13.3",
"esbuild": "^0.15.9",
"eval": "^0.1.8",
"express": "^4.17.1",
"fast-glob": "^3.2.7",
"fast-glob": "^3.2.12",
"fs-extra": "^10.0.0",
"history": "^5.0.1",
"ink": "^3.0.9",
"mlly": "^0.5.14",
"normalize-path": "^3.0.0",
"parse-json": "^5.2.0",
"mlly": "^0.5.16",
"pretty-ms": "^7.0.1",
"react": "^17.0.2",
"react-dom": "^17.0.2",
"resolve-from": "^5.0.0",
"rollup": "~2.78.1",
"rollup": "^2.79.1",
"rollup-plugin-dts": "^4.2.2",
"rollup-plugin-esbuild": "^4.10.1",
"rollup-plugin-node-externals": "^4.1.1",
"serialize-javascript": "^6.0.0",
"serve-handler": "^6.1.3",
"sort-package-json": "^1.57.0",
"used-styles": "^2.2.0",
"vite": "^3.0.9"
"vite": "^3.2.0-beta.0"
},
"devDependencies": {
"@types/babel__core": "^7.1.15",
"@types/express": "^4.17.13",
"@types/fs-extra": "^9.0.12",
"@types/node": "^16.11.57",
"@types/normalize-path": "^3.0.0",
"@types/react": "^17.0.19",
"@types/react-dom": "^17.0.9",
"@types/serialize-javascript": "^5.0.1",
"@types/serve-handler": "^6.1.1",
"ink-testing-library": "^2.1.0",
"memfs": "^3.4.7",
"strip-ansi": "^7.0.1",
"sync-dependencies": "^1.0.4",
"type-fest": "^2.18.0"
},
"peerDependencies": {
Expand Down
10 changes: 1 addition & 9 deletions packages/core/src/build.ts
Original file line number Diff line number Diff line change
Expand Up @@ -102,15 +102,6 @@ export const build = async (inlineConfig?: PartialConfig) => {
},
outDir: rendererDir,
},
// TODO: remove when this PR lands https://github.com/vitejs/vite/pull/9989
legacy: {
buildSsrCjsExternalHeuristics: true,
},
ssr: {
...commonBuildConfig.ssr,
format: 'cjs',
},
// TODO: end remove
})) as RollupOutput;

logger.info(`✅ Successfully built ${chalk.bold('renderer')}!`);
Expand All @@ -124,6 +115,7 @@ export const build = async (inlineConfig?: PartialConfig) => {
getIdentOption: () => 'short',
});

// TODO: use vite-node instead
const { renderAllPages } = (await import(
`${rendererDir}/${rendererOutput.fileName}`
)) as {
Expand Down
2 changes: 1 addition & 1 deletion packages/core/src/config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,7 @@ export const getConfig = (inlineConfig?: PartialConfig): EnhancedConfig => {
const appShell = determineAppShell(
inlineConfig,
resolveFromRoot,
) as `${string}.tsx`;
) as EnhancedConfig['appShell'];

return {
...config,
Expand Down