Skip to content

Commit 029097a

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

File tree

10 files changed

+161
-368
lines changed

10 files changed

+161
-368
lines changed

examples/vue/src/pages/ui/components/authenticator/sign-up-with-attributes/index.vue

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,8 @@ Amplify.configure(aws_exports);
2121
placeholder="Zone Info"
2222
name="zoneinfo"
2323
:hideLabel="false"
24+
:required="true"
25+
:disabled="false"
2426
/>
2527
</template>
2628
<template v-slot="{ user, signOut }">

packages/vue/jest.config.ts

Lines changed: 1 addition & 5 deletions
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

Lines changed: 8 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,12 @@
11
{
22
"name": "@aws-amplify/ui-vue",
33
"version": "4.2.30",
4-
"type": "module",
54
"main": "dist/index.cjs",
6-
"module": "dist/index.js",
5+
"module": "dist/esm/index.mjs",
76
"exports": {
87
".": {
98
"types": "./dist/index.d.ts",
10-
"import": "./dist/index.js",
9+
"import": "./dist/esm/index.mjs",
1110
"require": "./dist/index.cjs"
1211
},
1312
"./styles.css": "./dist/style.css"
@@ -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

Lines changed: 94 additions & 106 deletions
Original file line numberDiff line numberDiff line change
@@ -1,121 +1,109 @@
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';
238

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-
];
9+
// common config settings for Vue package (only has index.ts, not internal.ts or server.ts)
10+
const input = ['src/index.ts'];
11+
const esmOutputDir = 'dist/esm';
4012

4113
/**
4214
* @type {import('rollup').OutputOptions}
4315
*/
4416
const cjsOutput = {
45-
file: resolvePath('./dist/index.cjs'),
17+
dir: 'dist',
18+
entryFileNames: '[name].cjs',
19+
esModule: true,
4620
format: 'cjs',
47-
exports: 'named',
48-
sourcemap: sourceMap,
49-
globals: { vue: 'Vue' }
21+
generatedCode: { reservedNamesAsProps: false },
22+
interop: 'auto',
23+
exports: 'named'
5024
};
5125

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
26+
// shared plugins
27+
const vuePlugin = vue({
28+
compilerOptions: {
29+
isCustomElement: (tag) => tag.startsWith('amplify-')
30+
}
31+
});
32+
33+
// shared typescript configuration
34+
const typescriptConfig = {
35+
check: false, // disable type checking during build
36+
tsconfigOverride: {
37+
include: ['src/**/*'],
38+
exclude: ['**/__tests__/**/*'],
39+
compilerOptions: {
40+
declaration: true,
41+
declarationDir: 'dist',
42+
skipLibCheck: true,
43+
noImplicitAny: false,
44+
strictNullChecks: false
45+
}
46+
}
6047
};
6148

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-
});
49+
const config = defineConfig([
50+
// CJS config
51+
{
52+
input,
53+
output: cjsOutput,
54+
external: ['vue'],
55+
plugins: [
56+
externals({ include: [/node_modules/, /^@aws-amplify/] }),
57+
nodeResolve(),
58+
commonjs(),
59+
vuePlugin,
60+
postcss({
61+
extract: 'style.css',
62+
minimize: true,
63+
sourceMap: false
64+
}),
65+
typescript({
66+
...typescriptConfig
67+
}),
68+
],
69+
},
70+
// ESM config
71+
{
72+
input,
73+
output: {
74+
dir: esmOutputDir,
75+
format: 'es',
76+
entryFileNames: '[name].mjs',
77+
preserveModules: true,
78+
preserveModulesRoot: 'src',
79+
exports: 'named'
80+
},
81+
external: ['vue'],
82+
plugins: [
83+
externals({ include: [/node_modules/, /^@aws-amplify/] }),
84+
nodeResolve({
85+
extensions: ['.js', '.ts', '.vue']
86+
}),
87+
commonjs(),
88+
vuePlugin,
89+
postcss({
90+
extract: false,
91+
inject: false,
92+
sourceMap: false
93+
}),
94+
typescript({
95+
...typescriptConfig,
96+
outDir: esmOutputDir,
97+
tsconfigOverride: {
98+
...typescriptConfig.tsconfigOverride,
99+
compilerOptions: {
100+
...typescriptConfig.tsconfigOverride.compilerOptions,
101+
declaration: false
102+
}
103+
}
104+
}),
105+
],
106+
},
107+
]);
120108

121-
export default config;
109+
export default config;

packages/vue/scripts/copyCSS.ts

Lines changed: 9 additions & 0 deletions
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');
Lines changed: 23 additions & 0 deletions
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

Lines changed: 1 addition & 1 deletion
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

Lines changed: 3 additions & 17 deletions
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+
}

0 commit comments

Comments
 (0)