sku 14.3.0 → 14.4.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +28 -0
- package/bin.js +1 -1
- package/dist/config/fileResolutionExtensions.js +3 -3
- package/dist/context/createSkuContext.d.ts +3 -0
- package/dist/context/createSkuContext.js +1 -0
- package/dist/context/defaultSkuConfig.d.ts +2 -0
- package/dist/context/defaultSkuConfig.js +2 -0
- package/dist/program/commands/test/jest-test-handler.d.ts +6 -0
- package/dist/program/commands/test/jest-test-handler.js +20 -0
- package/dist/program/commands/test/test.action.js +6 -13
- package/dist/program/commands/test/vitest-test-handler.d.ts +5 -0
- package/dist/program/commands/test/vitest-test-handler.js +39 -0
- package/dist/services/vite/helpers/config/baseConfig.d.ts +3 -0
- package/dist/services/vite/helpers/{createConfig.js → config/baseConfig.js} +28 -43
- package/dist/services/vite/helpers/config/createConfig.d.ts +6 -0
- package/dist/services/vite/helpers/config/createConfig.js +87 -0
- package/dist/services/vite/helpers/server/createViteServerSsr.js +2 -18
- package/dist/services/vite/index.js +6 -7
- package/dist/services/vite/plugins/dangerouslySetViteConfig.d.ts +3 -0
- package/dist/services/vite/plugins/dangerouslySetViteConfig.js +6 -0
- package/dist/types/types.d.ts +26 -1
- package/package.json +11 -5
- package/dist/services/vite/helpers/createConfig.d.ts +0 -7
- package/dist/services/vite/helpers/server/createViteServer.d.ts +0 -2
- package/dist/services/vite/helpers/server/createViteServer.js +0 -29
- package/tsconfig.json +0 -31
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,33 @@
|
|
|
1
1
|
# sku
|
|
2
2
|
|
|
3
|
+
## 14.4.0
|
|
4
|
+
|
|
5
|
+
### Minor Changes
|
|
6
|
+
|
|
7
|
+
- `sku test`: Add experimental support for `vitest` ([#1271](https://github.com/seek-oss/sku/pull/1271))
|
|
8
|
+
|
|
9
|
+
> Note: this is an experimental feature. Do not use in production.
|
|
10
|
+
|
|
11
|
+
- Added `__unstableDangerouslySetViteConfig` to the sku config. ([#1276](https://github.com/seek-oss/sku/pull/1276))
|
|
12
|
+
|
|
13
|
+
This property is unstable and its implementation may change in future releases.
|
|
14
|
+
|
|
15
|
+
- Added `compilePackages` and `skipPackageCompatibilityCompilation` support to the Vite compiler. ([#1276](https://github.com/seek-oss/sku/pull/1276))
|
|
16
|
+
|
|
17
|
+
### Patch Changes
|
|
18
|
+
|
|
19
|
+
- Removed `tsconfig.json` from the published files. ([#1276](https://github.com/seek-oss/sku/pull/1276))
|
|
20
|
+
|
|
21
|
+
- Adding `babel-plugin-macros` to the Vite babel plugins ([#1276](https://github.com/seek-oss/sku/pull/1276))
|
|
22
|
+
|
|
23
|
+
- Modify root resolution extension order ([#1279](https://github.com/seek-oss/sku/pull/1279))
|
|
24
|
+
|
|
25
|
+
Fixes a bug that caused multiple versions of the same package to be bundled in certain situations
|
|
26
|
+
|
|
27
|
+
- Revert addition of `--disable-warning` flag to `sku` binary ([#1278](https://github.com/seek-oss/sku/pull/1278))
|
|
28
|
+
|
|
29
|
+
This flag was added to suppress certain warnings about experimental features being used by `sku`. However, the method use to set this flag is not compatible with certain distributions of Linux without additional configuration, so it has been removed.
|
|
30
|
+
|
|
3
31
|
## 14.3.0
|
|
4
32
|
|
|
5
33
|
### Minor Changes
|
package/bin.js
CHANGED
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
// TODO: Figure out a better way to share this config. This is currently copy-pasted from
|
|
2
2
|
// `eslint-config-seek`
|
|
3
3
|
export const extensions = {
|
|
4
|
-
js: ['
|
|
5
|
-
ts: ['
|
|
4
|
+
js: ['mjs', 'cjs', 'js', 'jsx'],
|
|
5
|
+
ts: ['mts', 'cts', 'ts', 'tsx'],
|
|
6
6
|
};
|
|
7
7
|
const prependDot = (ext) => `.${ext}`;
|
|
8
8
|
export const rootResolutionFileExtensions = [
|
|
9
|
-
...extensions.ts.map(prependDot),
|
|
10
9
|
...extensions.js.map(prependDot),
|
|
11
10
|
'.json',
|
|
11
|
+
...extensions.ts.map(prependDot),
|
|
12
12
|
];
|
|
@@ -10,10 +10,12 @@ export type NormalizedRoute = SkuRouteObject & {
|
|
|
10
10
|
};
|
|
11
11
|
export declare const createSkuContext: ({ configPath, port: portArg, strictPort, }: SkuContextOptions) => {
|
|
12
12
|
bundler: "webpack" | "vite";
|
|
13
|
+
testRunner: "vitest" | "jest";
|
|
13
14
|
configPath: string | undefined;
|
|
14
15
|
publicPath: string;
|
|
15
16
|
skuConfig: {
|
|
16
17
|
__UNSAFE_EXPERIMENTAL__bundler: "webpack" | "vite";
|
|
18
|
+
__UNSAFE_EXPERIMENTAL__testRunner: "vitest" | "jest";
|
|
17
19
|
clientEntry: string;
|
|
18
20
|
compilePackages: string[];
|
|
19
21
|
cspEnabled: boolean;
|
|
@@ -22,6 +24,7 @@ export declare const createSkuContext: ({ configPath, port: portArg, strictPort,
|
|
|
22
24
|
dangerouslySetJestConfig: (skuJestConfig: any) => any;
|
|
23
25
|
dangerouslySetTSConfig: (skuTSConfig: any) => any;
|
|
24
26
|
dangerouslySetWebpackConfig: (skuWebpackConfig: any) => any;
|
|
27
|
+
__unstableDangerouslySetViteConfig: import("rollup").ObjectHook<(this: void, config: import("vite").UserConfig, env: import("vite").ConfigEnv) => Omit<import("vite").UserConfig, "plugins"> | null | void | Promise<Omit<import("vite").UserConfig, "plugins"> | null | void>>;
|
|
25
28
|
devServerMiddleware: string;
|
|
26
29
|
displayNamesProd: boolean;
|
|
27
30
|
environments: readonly string[];
|
|
@@ -136,6 +136,7 @@ export const createSkuContext = ({ configPath, port: portArg, strictPort, }) =>
|
|
|
136
136
|
const externalizeNodeModules = skuConfig.externalizeNodeModules;
|
|
137
137
|
return {
|
|
138
138
|
bundler: skuConfig.__UNSAFE_EXPERIMENTAL__bundler,
|
|
139
|
+
testRunner: skuConfig.__UNSAFE_EXPERIMENTAL__testRunner,
|
|
139
140
|
configPath: appConfigPath,
|
|
140
141
|
publicPath,
|
|
141
142
|
skuConfig,
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
declare const _default: {
|
|
2
2
|
__UNSAFE_EXPERIMENTAL__bundler: "webpack";
|
|
3
|
+
__UNSAFE_EXPERIMENTAL__testRunner: "jest";
|
|
3
4
|
clientEntry: string;
|
|
4
5
|
renderEntry: string;
|
|
5
6
|
serverEntry: string;
|
|
@@ -27,6 +28,7 @@ declare const _default: {
|
|
|
27
28
|
dangerouslySetJestConfig: <T>(a: T) => T;
|
|
28
29
|
dangerouslySetESLintConfig: <T>(a: T) => T;
|
|
29
30
|
dangerouslySetTSConfig: <T>(a: T) => T;
|
|
31
|
+
__unstableDangerouslySetViteConfig: <T>(a: T) => T;
|
|
30
32
|
eslintIgnore: never[];
|
|
31
33
|
supportedBrowsers: string[];
|
|
32
34
|
cspEnabled: false;
|
|
@@ -4,6 +4,7 @@ import isCompilePackage from "../utils/isCompilePackage.js";
|
|
|
4
4
|
const defaultDecorator = (a) => a;
|
|
5
5
|
export default {
|
|
6
6
|
__UNSAFE_EXPERIMENTAL__bundler: 'webpack',
|
|
7
|
+
__UNSAFE_EXPERIMENTAL__testRunner: 'jest',
|
|
7
8
|
clientEntry: 'src/client.js',
|
|
8
9
|
renderEntry: 'src/render.js',
|
|
9
10
|
serverEntry: 'src/server.js',
|
|
@@ -31,6 +32,7 @@ export default {
|
|
|
31
32
|
dangerouslySetJestConfig: defaultDecorator,
|
|
32
33
|
dangerouslySetESLintConfig: defaultDecorator,
|
|
33
34
|
dangerouslySetTSConfig: defaultDecorator,
|
|
35
|
+
__unstableDangerouslySetViteConfig: defaultDecorator,
|
|
34
36
|
eslintIgnore: [],
|
|
35
37
|
supportedBrowsers: browserslistConfigSeek,
|
|
36
38
|
cspEnabled: false,
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import debug from 'debug';
|
|
2
|
+
import jest from 'jest';
|
|
3
|
+
import isCI from "../../../utils/isCI.js";
|
|
4
|
+
import { runVocabCompile } from "../../../services/vocab/runVocab.js";
|
|
5
|
+
import { configureProject } from "../../../utils/configure.js";
|
|
6
|
+
const log = debug('sku:jest');
|
|
7
|
+
const { run } = jest;
|
|
8
|
+
export const runJestTests = async ({ skuContext, }, { args = [] }) => {
|
|
9
|
+
await configureProject(skuContext);
|
|
10
|
+
await runVocabCompile(skuContext);
|
|
11
|
+
// https://jestjs.io/docs/configuration#preset-string
|
|
12
|
+
const jestPreset = 'sku';
|
|
13
|
+
log(`Using '${jestPreset}' Jest preset`);
|
|
14
|
+
const jestArgv = [...args];
|
|
15
|
+
jestArgv.push('--preset', jestPreset);
|
|
16
|
+
if (isCI) {
|
|
17
|
+
jestArgv.push('--ci');
|
|
18
|
+
}
|
|
19
|
+
run(jestArgv);
|
|
20
|
+
};
|
|
@@ -1,20 +1,13 @@
|
|
|
1
|
-
import debug from 'debug';
|
|
2
|
-
import jest from 'jest';
|
|
3
|
-
import isCI from "../../../utils/isCI.js";
|
|
4
1
|
import { runVocabCompile } from "../../../services/vocab/runVocab.js";
|
|
5
2
|
import { configureProject } from "../../../utils/configure.js";
|
|
6
|
-
|
|
7
|
-
|
|
3
|
+
import { runJestTests } from './jest-test-handler.js';
|
|
4
|
+
import { vitestHandler } from "./vitest-test-handler.js";
|
|
8
5
|
export const testAction = async ({ skuContext, }, { args = [] }) => {
|
|
9
6
|
await configureProject(skuContext);
|
|
10
7
|
await runVocabCompile(skuContext);
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
const jestArgv = [...args];
|
|
15
|
-
jestArgv.push('--preset', jestPreset);
|
|
16
|
-
if (isCI) {
|
|
17
|
-
jestArgv.push('--ci');
|
|
8
|
+
if (skuContext.testRunner === 'vitest') {
|
|
9
|
+
await vitestHandler({ skuContext, args });
|
|
10
|
+
return;
|
|
18
11
|
}
|
|
19
|
-
|
|
12
|
+
runJestTests({ skuContext }, { args });
|
|
20
13
|
};
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
import prompts from 'prompts';
|
|
2
|
+
import installDep from "../../../services/packageManager/install.js";
|
|
3
|
+
import isCI from "../../../utils/isCI.js";
|
|
4
|
+
export const vitestHandler = async ({ skuContext, args, }) => {
|
|
5
|
+
let vitestImport = null;
|
|
6
|
+
try {
|
|
7
|
+
vitestImport = await import('@sku-lib/vitest');
|
|
8
|
+
}
|
|
9
|
+
catch (e) {
|
|
10
|
+
if (e.code !== 'ERR_MODULE_NOT_FOUND' || isCI) {
|
|
11
|
+
console.error(e.message);
|
|
12
|
+
return;
|
|
13
|
+
}
|
|
14
|
+
// If @sku-lib/vitest is not installed, and we're not on CI we prompt to install.
|
|
15
|
+
console.log('@sku-lib/vitest is not installed');
|
|
16
|
+
const res = await prompts({
|
|
17
|
+
type: 'confirm',
|
|
18
|
+
name: 'install',
|
|
19
|
+
message: 'Do you want to install `@sku-lib/vitest`?',
|
|
20
|
+
initial: true,
|
|
21
|
+
}, { onCancel: () => process.exit(1) });
|
|
22
|
+
if (!res.install) {
|
|
23
|
+
console.log('Exiting without running tests.');
|
|
24
|
+
return;
|
|
25
|
+
}
|
|
26
|
+
await installDep({
|
|
27
|
+
deps: ['@sku-lib/vitest'],
|
|
28
|
+
type: 'dev',
|
|
29
|
+
logLevel: 'regular',
|
|
30
|
+
});
|
|
31
|
+
// Retry running Vitest after installation
|
|
32
|
+
await vitestHandler({ skuContext, args });
|
|
33
|
+
return;
|
|
34
|
+
}
|
|
35
|
+
await vitestImport.runVitest({
|
|
36
|
+
setupFiles: skuContext.paths.setupTests,
|
|
37
|
+
args,
|
|
38
|
+
});
|
|
39
|
+
};
|
|
@@ -1,30 +1,34 @@
|
|
|
1
|
-
import { createRequire
|
|
2
|
-
import
|
|
1
|
+
import { createRequire } from 'node:module';
|
|
2
|
+
import { mergeConfig } from 'vite';
|
|
3
3
|
import { cjsInterop } from 'vite-plugin-cjs-interop';
|
|
4
4
|
import { vanillaExtractPlugin } from '@vanilla-extract/vite-plugin';
|
|
5
|
-
import
|
|
6
|
-
import {
|
|
7
|
-
import {
|
|
8
|
-
import vocabPluginVite from '@vocab/vite';
|
|
9
|
-
import { getVocabConfig } from "../../vocab/config/vocab.js";
|
|
5
|
+
import react from '@vitejs/plugin-react';
|
|
6
|
+
import { preloadPlugin } from '../../plugins/preloadPlugin/preloadPlugin.js';
|
|
7
|
+
import { fixViteVanillaExtractDepScanPlugin } from "../../plugins/esbuild/fixViteVanillaExtractDepScanPlugin.js";
|
|
10
8
|
import { createVocabChunks } from '@vocab/vite/chunks';
|
|
11
9
|
import tsconfigPaths from 'vite-tsconfig-paths';
|
|
10
|
+
import { getVocabConfig } from "../../../vocab/config/vocab.js";
|
|
11
|
+
import vocabPluginVite from '@vocab/vite';
|
|
12
|
+
import { dangerouslySetViteConfig } from '../../plugins/dangerouslySetViteConfig.js';
|
|
12
13
|
const require = createRequire(import.meta.url);
|
|
13
|
-
const
|
|
14
|
-
export const createViteConfig = ({ skuContext, configType = 'client', plugins = [], }) => {
|
|
15
|
-
const input = {
|
|
16
|
-
client: clientEntry,
|
|
17
|
-
ssr: skuContext.paths.serverEntry,
|
|
18
|
-
ssg: skuContext.paths.renderEntry,
|
|
19
|
-
};
|
|
14
|
+
const getBaseConfig = (skuContext) => {
|
|
20
15
|
const vocabConfig = getVocabConfig(skuContext);
|
|
21
|
-
const isStartCommand = Boolean(skuContext.commandName?.startsWith('start'));
|
|
22
16
|
const isProductionBuild = process.env.NODE_ENV === 'production';
|
|
17
|
+
const prodBabelPlugins = [
|
|
18
|
+
[
|
|
19
|
+
require.resolve('babel-plugin-unassert'),
|
|
20
|
+
{
|
|
21
|
+
variables: ['assert', 'invariant'],
|
|
22
|
+
modules: ['assert', 'node:assert', 'tiny-invariant'],
|
|
23
|
+
},
|
|
24
|
+
],
|
|
25
|
+
];
|
|
23
26
|
return {
|
|
24
|
-
base:
|
|
27
|
+
base: skuContext.publicPath,
|
|
25
28
|
root: process.cwd(),
|
|
26
29
|
clearScreen: process.env.NODE_ENV !== 'test',
|
|
27
30
|
plugins: [
|
|
31
|
+
dangerouslySetViteConfig(skuContext),
|
|
28
32
|
vocabConfig && vocabPluginVite.default({ vocabConfig }),
|
|
29
33
|
tsconfigPaths(),
|
|
30
34
|
cjsInterop({
|
|
@@ -33,17 +37,8 @@ export const createViteConfig = ({ skuContext, configType = 'client', plugins =
|
|
|
33
37
|
react({
|
|
34
38
|
babel: {
|
|
35
39
|
plugins: [
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
[
|
|
39
|
-
require.resolve('babel-plugin-unassert'),
|
|
40
|
-
{
|
|
41
|
-
variables: ['assert', 'invariant'],
|
|
42
|
-
modules: ['assert', 'node:assert', 'tiny-invariant'],
|
|
43
|
-
},
|
|
44
|
-
],
|
|
45
|
-
]
|
|
46
|
-
: []),
|
|
40
|
+
require.resolve('babel-plugin-macros'),
|
|
41
|
+
...(isProductionBuild ? prodBabelPlugins : []),
|
|
47
42
|
],
|
|
48
43
|
},
|
|
49
44
|
}),
|
|
@@ -51,7 +46,6 @@ export const createViteConfig = ({ skuContext, configType = 'client', plugins =
|
|
|
51
46
|
preloadPlugin({
|
|
52
47
|
convertFromWebpack: skuContext.convertLoadable, // Convert loadable import from webpack to vite. Can be put behind a flag.
|
|
53
48
|
}),
|
|
54
|
-
...plugins,
|
|
55
49
|
],
|
|
56
50
|
resolve: {
|
|
57
51
|
alias: {
|
|
@@ -64,16 +58,11 @@ export const createViteConfig = ({ skuContext, configType = 'client', plugins =
|
|
|
64
58
|
'process.env.NODE_ENV': JSON.stringify(process.env.NODE_ENV),
|
|
65
59
|
},
|
|
66
60
|
build: {
|
|
67
|
-
outDir: outDir[configType],
|
|
68
61
|
emptyOutDir: true,
|
|
69
|
-
ssr: configType === 'ssr' || configType === 'ssg',
|
|
70
|
-
manifest: configType === 'client',
|
|
71
62
|
ssrManifest: false,
|
|
72
63
|
assetsDir: '',
|
|
73
64
|
rollupOptions: {
|
|
74
|
-
input: input[configType],
|
|
75
65
|
output: {
|
|
76
|
-
entryFileNames: configType === 'ssg' ? renderEntryChunkName : undefined,
|
|
77
66
|
experimentalMinChunkSize: undefined,
|
|
78
67
|
manualChunks: (id, ctx) => {
|
|
79
68
|
const languageChunkName = createVocabChunks(id, ctx);
|
|
@@ -88,19 +77,15 @@ export const createViteConfig = ({ skuContext, configType = 'client', plugins =
|
|
|
88
77
|
esbuildOptions: {
|
|
89
78
|
plugins: [fixViteVanillaExtractDepScanPlugin()],
|
|
90
79
|
},
|
|
80
|
+
exclude: skuContext.skuConfig.skipPackageCompatibilityCompilation,
|
|
91
81
|
},
|
|
92
82
|
ssr: {
|
|
93
|
-
external: [
|
|
94
|
-
|
|
95
|
-
'
|
|
96
|
-
|
|
97
|
-
'used-styles',
|
|
98
|
-
'@sku-lib/vite',
|
|
99
|
-
...(configType === 'ssg' || configType === 'ssr'
|
|
100
|
-
? ['sku/vite/loadable']
|
|
101
|
-
: []),
|
|
83
|
+
external: ['serialize-javascript', '@sku-lib/vite'],
|
|
84
|
+
noExternal: [
|
|
85
|
+
'braid-design-system',
|
|
86
|
+
...skuContext.skuConfig.compilePackages,
|
|
102
87
|
],
|
|
103
|
-
noExternal: ['@vanilla-extract/css', 'braid-design-system'],
|
|
104
88
|
},
|
|
105
89
|
};
|
|
106
90
|
};
|
|
91
|
+
export const createSkuViteConfig = (config, skuContext) => mergeConfig(getBaseConfig(skuContext), config);
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import type { SkuContext } from "../../../../context/createSkuContext.js";
|
|
2
|
+
export declare const createViteSsgConfig: (skuContext: SkuContext) => Record<string, any>;
|
|
3
|
+
export declare const createViteSsrConfig: (skuContext: SkuContext) => Record<string, any>;
|
|
4
|
+
export declare const createViteClientConfig: (skuContext: SkuContext) => Record<string, any>;
|
|
5
|
+
export declare const createViteDevConfig: (skuContext: SkuContext) => Record<string, any>;
|
|
6
|
+
export declare const createViteDevSsrConfig: (skuContext: SkuContext) => Record<string, any>;
|
|
@@ -0,0 +1,87 @@
|
|
|
1
|
+
import { createSkuViteConfig } from "./baseConfig.js";
|
|
2
|
+
import { outDir, renderEntryChunkName, } from "../bundleConfig.js";
|
|
3
|
+
import { createRequire } from 'node:module';
|
|
4
|
+
import { middlewarePlugin } from "../../plugins/middlewarePlugin.js";
|
|
5
|
+
import { startTelemetryPlugin } from "../../plugins/startTelemetry.js";
|
|
6
|
+
import { HMRTelemetryPlugin } from "../../plugins/HMRTelemetry.js";
|
|
7
|
+
import { httpsDevServerPlugin } from "../../plugins/httpsDevServerPlugin.js";
|
|
8
|
+
import { getAppHosts } from "../../../../utils/contextUtils/hosts.js";
|
|
9
|
+
const require = createRequire(import.meta.url);
|
|
10
|
+
const clientEntry = require.resolve('../../entries/vite-client.js');
|
|
11
|
+
export const createViteSsgConfig = (skuContext) => createSkuViteConfig({
|
|
12
|
+
build: {
|
|
13
|
+
ssr: true,
|
|
14
|
+
outDir: outDir.ssg,
|
|
15
|
+
rollupOptions: {
|
|
16
|
+
input: skuContext.paths.renderEntry,
|
|
17
|
+
output: {
|
|
18
|
+
entryFileNames: renderEntryChunkName,
|
|
19
|
+
},
|
|
20
|
+
},
|
|
21
|
+
},
|
|
22
|
+
}, skuContext);
|
|
23
|
+
export const createViteSsrConfig = (skuContext) => createSkuViteConfig({
|
|
24
|
+
build: {
|
|
25
|
+
ssr: true,
|
|
26
|
+
outDir: outDir.ssr,
|
|
27
|
+
rollupOptions: {
|
|
28
|
+
input: skuContext.paths.serverEntry,
|
|
29
|
+
},
|
|
30
|
+
},
|
|
31
|
+
}, skuContext);
|
|
32
|
+
export const createViteClientConfig = (skuContext) => createSkuViteConfig({
|
|
33
|
+
build: {
|
|
34
|
+
ssr: false,
|
|
35
|
+
outDir: outDir.client,
|
|
36
|
+
manifest: true,
|
|
37
|
+
rollupOptions: {
|
|
38
|
+
input: clientEntry,
|
|
39
|
+
},
|
|
40
|
+
},
|
|
41
|
+
}, skuContext);
|
|
42
|
+
export const createViteDevConfig = (skuContext) => createSkuViteConfig({
|
|
43
|
+
base: '/',
|
|
44
|
+
plugins: [
|
|
45
|
+
middlewarePlugin(skuContext),
|
|
46
|
+
startTelemetryPlugin({
|
|
47
|
+
target: 'node',
|
|
48
|
+
type: 'static',
|
|
49
|
+
}),
|
|
50
|
+
// eslint-disable-next-line new-cap
|
|
51
|
+
HMRTelemetryPlugin({
|
|
52
|
+
target: 'node',
|
|
53
|
+
type: 'static',
|
|
54
|
+
}),
|
|
55
|
+
httpsDevServerPlugin(skuContext),
|
|
56
|
+
],
|
|
57
|
+
build: {
|
|
58
|
+
ssr: false,
|
|
59
|
+
outDir: outDir.client,
|
|
60
|
+
manifest: true,
|
|
61
|
+
rollupOptions: {
|
|
62
|
+
input: clientEntry,
|
|
63
|
+
},
|
|
64
|
+
},
|
|
65
|
+
server: {
|
|
66
|
+
host: 'localhost',
|
|
67
|
+
allowedHosts: getAppHosts(skuContext).filter((host) => typeof host === 'string'),
|
|
68
|
+
},
|
|
69
|
+
}, skuContext);
|
|
70
|
+
export const createViteDevSsrConfig = (skuContext) => createSkuViteConfig({
|
|
71
|
+
build: {
|
|
72
|
+
ssr: true,
|
|
73
|
+
outDir: outDir.ssr,
|
|
74
|
+
rollupOptions: {
|
|
75
|
+
input: skuContext.paths.serverEntry,
|
|
76
|
+
},
|
|
77
|
+
},
|
|
78
|
+
server: {
|
|
79
|
+
host: 'localhost',
|
|
80
|
+
middlewareMode: true,
|
|
81
|
+
hmr: true,
|
|
82
|
+
allowedHosts: getAppHosts(skuContext).filter((host) => typeof host === 'string'),
|
|
83
|
+
},
|
|
84
|
+
plugins: [httpsDevServerPlugin(skuContext)],
|
|
85
|
+
appType: 'custom',
|
|
86
|
+
base: '/',
|
|
87
|
+
}, skuContext);
|
|
@@ -3,11 +3,9 @@ import { Transform } from 'node:stream';
|
|
|
3
3
|
import express from 'express';
|
|
4
4
|
import crypto from 'node:crypto';
|
|
5
5
|
import { readFile } from 'node:fs/promises';
|
|
6
|
-
import {
|
|
6
|
+
import { createViteDevSsrConfig } from "../config/createConfig.js";
|
|
7
7
|
import { createSsrHtml } from "../html/createSsrHtml.js";
|
|
8
8
|
import { createCollector } from '@sku-lib/vite/collector';
|
|
9
|
-
import { getAppHosts } from "../../../../utils/contextUtils/hosts.js";
|
|
10
|
-
import { httpsDevServerPlugin } from '../../plugins/httpsDevServerPlugin.js';
|
|
11
9
|
const base = process.env.BASE || '/';
|
|
12
10
|
const resolve = (p) => path.resolve(process.cwd(), p);
|
|
13
11
|
export const createViteServerSsr = async ({ skuContext, }) => {
|
|
@@ -20,21 +18,7 @@ export const createViteServerSsr = async ({ skuContext, }) => {
|
|
|
20
18
|
let vite;
|
|
21
19
|
if (!isProduction) {
|
|
22
20
|
const { createServer: createViteSever } = await import('vite');
|
|
23
|
-
vite = await createViteSever(
|
|
24
|
-
...createViteConfig({
|
|
25
|
-
skuContext,
|
|
26
|
-
configType: 'ssr',
|
|
27
|
-
}),
|
|
28
|
-
server: {
|
|
29
|
-
host: 'localhost',
|
|
30
|
-
middlewareMode: true,
|
|
31
|
-
hmr: true,
|
|
32
|
-
allowedHosts: getAppHosts(skuContext).filter((host) => typeof host === 'string'),
|
|
33
|
-
},
|
|
34
|
-
plugins: [httpsDevServerPlugin(skuContext)],
|
|
35
|
-
appType: 'custom',
|
|
36
|
-
base,
|
|
37
|
-
});
|
|
21
|
+
vite = await createViteSever(createViteDevSsrConfig(skuContext));
|
|
38
22
|
app.use(vite.middlewares);
|
|
39
23
|
}
|
|
40
24
|
else {
|
|
@@ -1,7 +1,6 @@
|
|
|
1
|
-
import { build } from 'vite';
|
|
2
|
-
import { createViteServer } from './helpers/server/createViteServer.js';
|
|
1
|
+
import { build, createServer } from 'vite';
|
|
3
2
|
import { createViteServerSsr } from './helpers/server/createViteServerSsr.js';
|
|
4
|
-
import {
|
|
3
|
+
import { createViteClientConfig, createViteDevConfig, createViteSsgConfig, } from './helpers/config/createConfig.js';
|
|
5
4
|
import { cleanTargetDirectory } from "../../utils/buildFileUtils.js";
|
|
6
5
|
import { openBrowser } from "../../openBrowser/index.js";
|
|
7
6
|
import { getAppHosts } from "../../utils/contextUtils/hosts.js";
|
|
@@ -11,11 +10,11 @@ import allocatePort from "../../utils/allocatePort.js";
|
|
|
11
10
|
export const viteService = {
|
|
12
11
|
buildSsr: async (skuContext) => {
|
|
13
12
|
// TODO: This isn't fully implemented?
|
|
14
|
-
await build(
|
|
13
|
+
await build(createViteClientConfig(skuContext));
|
|
15
14
|
},
|
|
16
15
|
build: async (skuContext) => {
|
|
17
|
-
await build(
|
|
18
|
-
await build(
|
|
16
|
+
await build(createViteClientConfig(skuContext));
|
|
17
|
+
await build(createViteSsgConfig(skuContext));
|
|
19
18
|
if (skuContext.routes) {
|
|
20
19
|
await prerenderConcurrently(skuContext);
|
|
21
20
|
}
|
|
@@ -24,7 +23,7 @@ export const viteService = {
|
|
|
24
23
|
},
|
|
25
24
|
start: async (skuContext) => {
|
|
26
25
|
// TODO Get this to be backwards compat with webpack
|
|
27
|
-
const server = await
|
|
26
|
+
const server = await createServer(createViteDevConfig(skuContext));
|
|
28
27
|
const availablePort = await allocatePort({
|
|
29
28
|
port: skuContext.port.client,
|
|
30
29
|
host: '0.0.0.0',
|
package/dist/types/types.d.ts
CHANGED
|
@@ -1,7 +1,8 @@
|
|
|
1
|
-
import type { ReactNode } from 'react';
|
|
1
|
+
import type { ReactNode, JSX } from 'react';
|
|
2
2
|
import type { Express, RequestHandler } from 'express';
|
|
3
3
|
import type { ChunkExtractor } from '@loadable/server';
|
|
4
4
|
import type { Linter } from 'eslint';
|
|
5
|
+
import type { Plugin } from 'vite';
|
|
5
6
|
export type ViteRenderFunction = (options: {
|
|
6
7
|
clientEntry: string;
|
|
7
8
|
} & SharedRenderProps) => Promise<string>;
|
|
@@ -94,6 +95,15 @@ export interface SkuConfig {
|
|
|
94
95
|
* @default "webpack"
|
|
95
96
|
*/
|
|
96
97
|
__UNSAFE_EXPERIMENTAL__bundler?: 'webpack' | 'vite';
|
|
98
|
+
/**
|
|
99
|
+
* The test runner that sku uses to run the tests.
|
|
100
|
+
* This is an experimental option that may change or be removed without notice.
|
|
101
|
+
*
|
|
102
|
+
* NOTE: Not all sku functionality is supported by the `vitest` option.
|
|
103
|
+
*
|
|
104
|
+
* @default: "jest"
|
|
105
|
+
*/
|
|
106
|
+
__UNSAFE_EXPERIMENTAL__testRunner?: 'vitest' | 'jest';
|
|
97
107
|
/**
|
|
98
108
|
* The client entry point to the app. The client entry is the file that executes your browser code.
|
|
99
109
|
*
|
|
@@ -183,6 +193,21 @@ export interface SkuConfig {
|
|
|
183
193
|
* @link https://seek-oss.github.io/sku/#/./docs/configuration?id=dangerouslysetwebpackconfig
|
|
184
194
|
*/
|
|
185
195
|
dangerouslySetWebpackConfig?: (skuWebpackConfig: any) => any;
|
|
196
|
+
/**
|
|
197
|
+
* This function provides a way to modify sku's Vite configuration.
|
|
198
|
+
* It should only be used in exceptional circumstances where a solution cannot be achieved by adjusting standard configuration options.
|
|
199
|
+
*
|
|
200
|
+
* Before customizing your Vite configuration, please reach out in [#sku-support](https://seek.enterprise.slack.com/archives/CDL5VP5NU) to discuss your requirements and potential alternative solutions.
|
|
201
|
+
*
|
|
202
|
+
* As sku creates two Vite configs (`client` & `server|render`), this function will actually run twice.
|
|
203
|
+
* If you only need to modify one of these configs, then you can check `env.mode` from the second argument within.
|
|
204
|
+
*
|
|
205
|
+
* Sku provides no guarantees that its Vite configuration will remain compatible with any customizations made within this function.
|
|
206
|
+
* It is the responsibility of the user to ensure that their customizations are compatible with sku.
|
|
207
|
+
*
|
|
208
|
+
* @link https://seek-oss.github.io/sku/#/./docs/configuration?id=dangerouslysetviteconfig
|
|
209
|
+
*/
|
|
210
|
+
__unstableDangerouslySetViteConfig?: Plugin['config'];
|
|
186
211
|
/**
|
|
187
212
|
* Path to a file in your project that exports a function that can receive the Express server.
|
|
188
213
|
* This can be used to extend to the dev server middleware.
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "sku",
|
|
3
|
-
"version": "14.
|
|
3
|
+
"version": "14.4.0",
|
|
4
4
|
"description": "Front-end development toolkit, powered by Webpack, Babel, Vanilla Extract and Jest",
|
|
5
5
|
"types": "./dist/index.d.ts",
|
|
6
6
|
"bin": {
|
|
@@ -41,7 +41,6 @@
|
|
|
41
41
|
"scripts",
|
|
42
42
|
"template",
|
|
43
43
|
"CHANGELOG.md",
|
|
44
|
-
"tsconfig.json",
|
|
45
44
|
"src/@loadable",
|
|
46
45
|
"bin.js"
|
|
47
46
|
],
|
|
@@ -58,6 +57,7 @@
|
|
|
58
57
|
},
|
|
59
58
|
"homepage": "https://github.com/seek-oss/sku#readme",
|
|
60
59
|
"peerDependencies": {
|
|
60
|
+
"@sku-lib/vitest": "*",
|
|
61
61
|
"@storybook/react-webpack5": "^7.0.0 || ^8.0.0",
|
|
62
62
|
"@types/react": "^18.0.0",
|
|
63
63
|
"react": "^18.0.0",
|
|
@@ -69,6 +69,9 @@
|
|
|
69
69
|
},
|
|
70
70
|
"react-dom": {
|
|
71
71
|
"optional": true
|
|
72
|
+
},
|
|
73
|
+
"@sku-lib/vitest": {
|
|
74
|
+
"optional": true
|
|
72
75
|
}
|
|
73
76
|
},
|
|
74
77
|
"dependencies": {
|
|
@@ -160,6 +163,7 @@
|
|
|
160
163
|
"postcss-loader": "^8.0.0",
|
|
161
164
|
"prettier": "~3.5.0",
|
|
162
165
|
"pretty-ms": "^9.2.0",
|
|
166
|
+
"prompts": "^2.4.2",
|
|
163
167
|
"react-refresh": "^0.17.0",
|
|
164
168
|
"resolve-from": "^5.0.0",
|
|
165
169
|
"selfsigned": "^2.1.1",
|
|
@@ -178,8 +182,7 @@
|
|
|
178
182
|
"webpack-dev-server": "^5.0.2",
|
|
179
183
|
"webpack-merge": "^6.0.1",
|
|
180
184
|
"webpack-node-externals": "^3.0.0",
|
|
181
|
-
"wrap-ansi": "^9.0.0"
|
|
182
|
-
"@sku-lib/vite": "0.1.0"
|
|
185
|
+
"wrap-ansi": "^9.0.0"
|
|
183
186
|
},
|
|
184
187
|
"devDependencies": {
|
|
185
188
|
"@jest/globals": "^29.7.0",
|
|
@@ -195,6 +198,7 @@
|
|
|
195
198
|
"@types/loadable__webpack-plugin": "^5.7.6",
|
|
196
199
|
"@types/node": "^18.19.31",
|
|
197
200
|
"@types/picomatch": "^2.3.3",
|
|
201
|
+
"@types/prompts": "^2.4.9",
|
|
198
202
|
"@types/react": "^18.2.3",
|
|
199
203
|
"@types/react-dom": "^18.2.3",
|
|
200
204
|
"@types/semver": "^7.5.8",
|
|
@@ -213,7 +217,9 @@
|
|
|
213
217
|
"react-router-dom": "^6.0.0",
|
|
214
218
|
"ts-patch": "^3.3.0",
|
|
215
219
|
"typescript-transform-paths": "^3.5.2",
|
|
216
|
-
"vitest": "^3.1.1"
|
|
220
|
+
"vitest": "^3.1.1",
|
|
221
|
+
"@sku-lib/vite": "0.1.0",
|
|
222
|
+
"@sku-lib/vitest": "0.1.0"
|
|
217
223
|
},
|
|
218
224
|
"scripts": {
|
|
219
225
|
"postinstall": "node ./scripts/postinstall.js",
|
|
@@ -1,7 +0,0 @@
|
|
|
1
|
-
import type { InlineConfig } from 'vite';
|
|
2
|
-
import type { SkuContext } from "../../../context/createSkuContext.js";
|
|
3
|
-
export declare const createViteConfig: ({ skuContext, configType, plugins, }: {
|
|
4
|
-
skuContext: SkuContext;
|
|
5
|
-
configType?: "client" | "ssr" | "ssg";
|
|
6
|
-
plugins?: InlineConfig["plugins"];
|
|
7
|
-
}) => InlineConfig;
|
|
@@ -1,29 +0,0 @@
|
|
|
1
|
-
import { middlewarePlugin } from "../../plugins/middlewarePlugin.js";
|
|
2
|
-
import { createServer } from 'vite';
|
|
3
|
-
import { createViteConfig } from '../createConfig.js';
|
|
4
|
-
import { HMRTelemetryPlugin } from "../../plugins/HMRTelemetry.js";
|
|
5
|
-
import { startTelemetryPlugin } from '../../plugins/startTelemetry.js';
|
|
6
|
-
import { getAppHosts } from "../../../../utils/contextUtils/hosts.js";
|
|
7
|
-
import { httpsDevServerPlugin } from '../../plugins/httpsDevServerPlugin.js';
|
|
8
|
-
export const createViteServer = async (skuContext) => createServer({
|
|
9
|
-
...createViteConfig({
|
|
10
|
-
skuContext,
|
|
11
|
-
plugins: [
|
|
12
|
-
middlewarePlugin(skuContext),
|
|
13
|
-
startTelemetryPlugin({
|
|
14
|
-
target: 'node',
|
|
15
|
-
type: 'static',
|
|
16
|
-
}),
|
|
17
|
-
// eslint-disable-next-line new-cap
|
|
18
|
-
HMRTelemetryPlugin({
|
|
19
|
-
target: 'node',
|
|
20
|
-
type: 'static',
|
|
21
|
-
}),
|
|
22
|
-
httpsDevServerPlugin(skuContext),
|
|
23
|
-
],
|
|
24
|
-
}),
|
|
25
|
-
server: {
|
|
26
|
-
host: 'localhost',
|
|
27
|
-
allowedHosts: getAppHosts(skuContext).filter((host) => typeof host === 'string'),
|
|
28
|
-
},
|
|
29
|
-
});
|
package/tsconfig.json
DELETED
|
@@ -1,31 +0,0 @@
|
|
|
1
|
-
{
|
|
2
|
-
"extends": "@tsconfig/node-lts/tsconfig.json",
|
|
3
|
-
"compilerOptions": {
|
|
4
|
-
"rootDir": "./src",
|
|
5
|
-
"target": "ESNext",
|
|
6
|
-
"allowJs": true,
|
|
7
|
-
"jsx": "react-jsx",
|
|
8
|
-
"module": "nodenext",
|
|
9
|
-
"baseUrl": ".",
|
|
10
|
-
"moduleResolution": "nodenext",
|
|
11
|
-
"allowSyntheticDefaultImports": true,
|
|
12
|
-
"resolveJsonModule": true,
|
|
13
|
-
"skipLibCheck": true,
|
|
14
|
-
"esModuleInterop": true,
|
|
15
|
-
"declaration": true,
|
|
16
|
-
"types": ["webpack/module", "jest", "node"],
|
|
17
|
-
"lib": ["ESNext", "DOM"],
|
|
18
|
-
"paths": {
|
|
19
|
-
"@/*": ["src/*"]
|
|
20
|
-
},
|
|
21
|
-
"plugins": [
|
|
22
|
-
// Transform paths in output .js files
|
|
23
|
-
{ "transform": "typescript-transform-paths" },
|
|
24
|
-
|
|
25
|
-
// Transform paths in output .d.ts files (Include this line if you output declarations files)
|
|
26
|
-
{ "transform": "typescript-transform-paths", "afterDeclarations": true }
|
|
27
|
-
]
|
|
28
|
-
},
|
|
29
|
-
"include": ["./src/**/*"],
|
|
30
|
-
"exclude": ["node_modules", "**/@loadable"]
|
|
31
|
-
}
|