Skip to content

Commit 07413ea

Browse files
committed
Aligned with already existed configs from other packages. Removed exccessive unnecessary sutff
1 parent b206bc4 commit 07413ea

File tree

9 files changed

+152
-367
lines changed

9 files changed

+152
-367
lines changed

packages/vue/jest.config.ts

+1-5
Original file line numberDiff line numberDiff line change
@@ -27,10 +27,8 @@ const config: Config = {
2727
moduleNameMapper: {
2828
'\\.css$': '<rootDir>/__mocks__/styleMock.js',
2929
'^nanoid$': '<rootDir>/../../node_modules/nanoid',
30-
'^@/(.*)$': '<rootDir>/src/$1',
31-
'^./src/components/(.*)$': '<rootDir>/src/components/$1',
3230
},
33-
modulePathIgnorePatterns: ['<rootDir>/dist/', '<rootDir>/.rollup.cache/'],
31+
modulePathIgnorePatterns: ['<rootDir>/dist/'],
3432
setupFilesAfterEnv: ['./jest.setup.ts'],
3533
transform: {
3634
'^.+\\.(ts)$': 'ts-jest',
@@ -40,8 +38,6 @@ const config: Config = {
4038
testEnvironmentOptions: {
4139
customExportConditions: ['node', 'node-addons'],
4240
},
43-
roots: ['<rootDir>/src', '<rootDir>/__tests__'],
44-
testRegex: '(/__tests__/.*|(\\.|/)(test|spec))\\.(jsx?|tsx?|vue)$',
4541
};
4642

4743
export default config;

packages/vue/package.json

+6-10
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
{
22
"name": "@aws-amplify/ui-vue",
33
"version": "4.2.30",
4-
"type": "module",
54
"main": "dist/index.cjs",
65
"module": "dist/index.js",
76
"exports": {
@@ -28,8 +27,11 @@
2827
],
2928
"scripts": {
3029
"prebuild": "rimraf dist",
31-
"build": "rollup -c",
32-
"dev": "rollup -c -w",
30+
"build": "yarn build:catalog && yarn build:CSS && yarn build:rollup",
31+
"build:catalog": "yarn node -r esbuild-register scripts/generatePrimitiveCatalog.ts",
32+
"build:CSS": "yarn node -r esbuild-register scripts/copyCSS.ts",
33+
"build:rollup": "rollup --config",
34+
"dev": "yarn build:rollup --watch",
3335
"clean": "rimraf dist node_modules",
3436
"check:esm": "node --input-type=module --eval 'import \"@aws-amplify/ui-vue\"'",
3537
"lint": "yarn typecheck && eslint . --ext .vue,.js,.jsx,.ts,.tsx",
@@ -49,12 +51,9 @@
4951
"@babel/core": "^7.23.2",
5052
"@babel/preset-env": "^7.23.2",
5153
"@rollup/plugin-alias": "^5.1.1",
52-
"@rollup/plugin-commonjs": "^28.0.3",
5354
"@rollup/plugin-dynamic-import-vars": "^1.4.0",
5455
"@rollup/plugin-node-resolve": "^16.0.0",
55-
"@rollup/plugin-typescript": "^12.1.2",
5656
"@rushstack/eslint-patch": "^1.5.1",
57-
"@testing-library/jest-dom": "^6.6.3",
5857
"@testing-library/vue": "^6.6.0",
5958
"@types/node": "18.8.0",
6059
"@vue/babel-plugin-jsx": "^1.2.2",
@@ -64,19 +63,16 @@
6463
"@vue/test-utils": "^2.4.1",
6564
"@vue/vue3-jest": "^29.2.6",
6665
"babel-jest": "^29.7.0",
67-
"esbuild": "^0.25.1",
6866
"eslint-plugin-vue": "^9.17.0",
69-
"rollup": "^4.35.0",
7067
"rollup-plugin-esbuild": "^6.2.1",
71-
"rollup-plugin-node-externals": "^7.1.3",
7268
"rollup-plugin-postcss": "^4.0.2",
7369
"rollup-plugin-typescript2": "^0.31.2",
7470
"rollup-plugin-vue": "^6.0.0",
7571
"unplugin-vue-components": "^0.25.0"
7672
},
7773
"peerDependencies": {
7874
"@aws-amplify/core": "*",
79-
"aws-amplify": "^6.9.0",
75+
"aws-amplify": "*",
8076
"vue": "^3.0"
8177
}
8278
}

packages/vue/rollup.config.mjs

+89-107
Original file line numberDiff line numberDiff line change
@@ -1,121 +1,103 @@
11
import { defineConfig } from 'rollup';
2-
import { fileURLToPath } from 'url';
3-
import path from 'path';
2+
import typescript from 'rollup-plugin-typescript2';
3+
import externals from 'rollup-plugin-node-externals';
4+
import postcss from 'rollup-plugin-postcss';
45
import vue from 'rollup-plugin-vue';
6+
import { nodeResolve } from '@rollup/plugin-node-resolve';
57
import commonjs from '@rollup/plugin-commonjs';
6-
import resolve from '@rollup/plugin-node-resolve';
7-
import postcss from 'rollup-plugin-postcss';
8-
import dynamicImportVars from '@rollup/plugin-dynamic-import-vars';
9-
import externals from 'rollup-plugin-node-externals';
10-
import esbuild from 'rollup-plugin-esbuild';
11-
import typescript2 from 'rollup-plugin-typescript2';
12-
13-
// ES Module equivalent for __dirname
14-
const __filename = fileURLToPath(import.meta.url);
15-
const __dirname = path.dirname(__filename);
16-
17-
const resolvePath = (str) => path.resolve(__dirname, str);
18-
19-
// common config settings
20-
const input = 'src/index.ts';
21-
const sourceMap = true;
22-
const tsconfig = 'tsconfig.dist.json';
23-
24-
// External dependencies that shouldn't be bundled
25-
const external = [
26-
'@aws-amplify/auth',
27-
'@aws-amplify/core',
28-
'@aws-amplify/core/internals/utils',
29-
'aws-amplify',
30-
'aws-amplify/auth',
31-
'aws-amplify/core',
32-
'aws-amplify/utils',
33-
'vue',
34-
'qrcode',
35-
'nanoid',
36-
'@vueuse/core',
37-
'@xstate/vue',
38-
'xstate'
39-
];
408

9+
// common config settings for Vue package (only has index.ts, not internal.ts or server.ts)
10+
const input = ['src/index.ts'];
4111
/**
4212
* @type {import('rollup').OutputOptions}
4313
*/
4414
const cjsOutput = {
45-
file: resolvePath('./dist/index.cjs'),
15+
dir: 'dist',
16+
entryFileNames: '[name].cjs',
17+
esModule: true,
4618
format: 'cjs',
47-
exports: 'named',
48-
sourcemap: sourceMap,
49-
globals: { vue: 'Vue' }
19+
generatedCode: { reservedNamesAsProps: false },
20+
interop: 'auto',
21+
exports: 'named'
5022
};
5123

52-
/**
53-
* @type {import('rollup').OutputOptions}
54-
*/
55-
const esmOutput = {
56-
file: resolvePath('./dist/index.js'),
57-
format: 'es',
58-
exports: 'named',
59-
sourcemap: sourceMap
24+
// shared plugins
25+
const vuePlugin = vue({
26+
compilerOptions: {
27+
isCustomElement: (tag) => tag.startsWith('amplify-')
28+
}
29+
});
30+
31+
// shared typescript configuration
32+
const typescriptConfig = {
33+
check: false, // disable type checking during build
34+
tsconfigOverride: {
35+
include: ['src/**/*'],
36+
exclude: ['**/__tests__/**/*'],
37+
compilerOptions: {
38+
declaration: true,
39+
declarationDir: 'dist',
40+
skipLibCheck: true,
41+
noImplicitAny: false,
42+
strictNullChecks: false
43+
}
44+
}
6045
};
6146

62-
// Following React's approach with Vue-specific additions
63-
const config = defineConfig({
64-
input: resolvePath(input),
65-
output: [cjsOutput, esmOutput],
66-
external,
67-
plugins: [
68-
// Exclude test files and node_modules
69-
externals({
70-
exclude: ['tslib'],
71-
}),
72-
resolve({
73-
extensions: ['.js', '.ts', '.vue']
74-
}),
75-
commonjs(),
76-
// Vue-specific plugins
77-
vue({
78-
preprocessStyles: true,
79-
template: {
80-
isProduction: true
81-
}
82-
}),
83-
postcss({
84-
extract: 'style.css',
85-
minimize: true,
86-
sourceMap: true
87-
}),
88-
// Use typescript2 for proper declaration file generation
89-
typescript2({
90-
check: false,
91-
tsconfig: resolvePath(tsconfig),
92-
tsconfigOverride: {
93-
compilerOptions: {
94-
sourceMap: true,
95-
declaration: true,
96-
declarationMap: true,
97-
outDir: resolvePath('./dist'),
98-
declarationDir: resolvePath('./dist')
99-
},
100-
exclude: [
101-
"**/__tests__/**",
102-
"**/__mocks__/**",
103-
"**/*.spec.ts",
104-
"global-spec.ts",
105-
"node_modules"
106-
]
107-
}
108-
}),
109-
// Use esbuild for faster JavaScript transpilation
110-
esbuild({
111-
include: /\.[jt]sx?$/,
112-
exclude: /node_modules|__tests__|__mocks__/,
113-
sourceMap: true,
114-
target: 'es2015',
115-
tsconfig: resolvePath(tsconfig)
116-
}),
117-
dynamicImportVars
118-
]
119-
});
47+
const config = defineConfig([
48+
// CJS config
49+
{
50+
input,
51+
output: cjsOutput,
52+
external: ['vue'],
53+
plugins: [
54+
externals({ include: [/node_modules/, /^@aws-amplify/] }),
55+
nodeResolve(),
56+
commonjs(),
57+
vuePlugin,
58+
postcss({
59+
extract: 'style.css',
60+
minimize: true,
61+
sourceMap: false
62+
}),
63+
typescript({
64+
...typescriptConfig
65+
}),
66+
],
67+
},
68+
// ESM config
69+
{
70+
input,
71+
output: {
72+
dir: 'dist',
73+
format: 'es',
74+
entryFileNames: '[name].js',
75+
preserveModules: false,
76+
exports: 'named'
77+
},
78+
external: ['vue'],
79+
plugins: [
80+
externals({ include: [/node_modules/, /^@aws-amplify/] }),
81+
nodeResolve(),
82+
commonjs(),
83+
vuePlugin,
84+
postcss({
85+
extract: false,
86+
inject: false,
87+
sourceMap: false
88+
}),
89+
typescript({
90+
...typescriptConfig,
91+
tsconfigOverride: {
92+
...typescriptConfig.tsconfigOverride,
93+
compilerOptions: {
94+
...typescriptConfig.tsconfigOverride.compilerOptions,
95+
declaration: false
96+
}
97+
}
98+
}),
99+
],
100+
},
101+
]);
120102

121-
export default config;
103+
export default config;

packages/vue/scripts/copyCSS.ts

+9
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
import fs from 'fs-extra';
2+
3+
// Ensure the directory exists
4+
fs.ensureDirSync('dist');
5+
6+
// Copy CSS files from the UI package
7+
fs.copySync('../ui/dist/styles.css', 'dist/style.css', { overwrite: true });
8+
9+
console.log('CSS files copied successfully');
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
// This is a simplified version of the React primitive catalog generator
2+
// It creates an empty catalog file since Vue may have different component structure
3+
4+
import fs from 'fs';
5+
import path from 'path';
6+
7+
// Empty catalog object
8+
const catalog = {};
9+
10+
// Ensure the dist directory exists before writing to it
11+
const distDir = path.resolve(__dirname, '..', 'dist');
12+
if (!fs.existsSync(distDir)) {
13+
fs.mkdirSync(distDir, { recursive: true });
14+
}
15+
16+
// Write the catalog to a file
17+
fs.writeFileSync(
18+
path.resolve(distDir, 'primitives.json'),
19+
JSON.stringify(catalog, null, 2),
20+
{ flag: 'w' }
21+
);
22+
23+
console.log('Primitive catalog generated successfully');

packages/vue/src/components/__tests__/authenticator.spec.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -170,7 +170,7 @@ describe('authenticator', () => {
170170
});
171171

172172
it.each(routesWithComponent)('renders %s subcomponent', (route) => {
173-
let user = undefined;
173+
let user: { username: string } | undefined = undefined;
174174
const challengeName = 'SOFTWARE_TOKEN_MFA';
175175

176176
// some routes expect specific shape of user

packages/vue/tsconfig.dist.json

+3-17
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,5 @@
11
{
22
"extends": "./tsconfig.json",
3-
"compilerOptions": {
4-
"declaration": true,
5-
"declarationDir": "dist",
6-
"outDir": "dist",
7-
"sourceMap": true,
8-
"rootDir": "src"
9-
},
10-
"include": ["src/**/*.ts", "src/**/*.tsx", "src/**/*.vue"],
11-
"exclude": [
12-
"__tests__",
13-
"__mocks__",
14-
"node_modules",
15-
"**/*.spec.ts",
16-
"**/__tests__/**",
17-
"global-spec.ts"
18-
]
19-
}
3+
"include": ["src/**/*.ts", "src/**/*.tsx"],
4+
"exclude": ["node_modules", "**/__mocks__", "**/__tests__"]
5+
}

packages/vue/tsconfig.json

+9-14
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,15 @@
11
{
22
"extends": "@aws-amplify/typescript-config/tsconfig.vue.json",
3-
"include": [
4-
"src/**/*",
5-
"types/**/*",
6-
"*.d.ts",
7-
"*.ts",
8-
"__tests__/**/*",
9-
"global-spec.ts"
10-
],
113
"compilerOptions": {
4+
"noImplicitAny": false,
5+
"skipLibCheck": true,
126
"types": [
137
"node",
148
"jest",
15-
"@testing-library/jest-dom"
16-
],
17-
"composite": true,
18-
"rootDir": "."
19-
}
20-
}
9+
"@testing-library/jest-dom",
10+
"vite/client"
11+
]
12+
},
13+
"include": ["*.ts", "*.mjs", "scripts", "src/**/*.ts", "src/**/*.tsx", "src/**/*.vue"],
14+
"exclude": ["node_modules", "dist"]
15+
}

0 commit comments

Comments
 (0)