@shoplflow/base 0.0.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.
@@ -0,0 +1,3 @@
1
+ {
2
+ "presets": ["@babel/preset-env", "@babel/typescript"],
3
+ }
package/build.cjs ADDED
@@ -0,0 +1,62 @@
1
+ const { context } = require('esbuild');
2
+ const { Generator } = require('npm-dts');
3
+
4
+ const { dependencies, peerDependencies } = require('./package.json');
5
+
6
+
7
+ const externals = peerDependencies ? Object.keys(dependencies).concat(Object.keys(peerDependencies)) : Object.keys(dependencies);
8
+
9
+ const sharedConfig = {
10
+ entryPoints: ['src/index.ts'],
11
+ bundle: true,
12
+ minify: true,
13
+ external: externals,
14
+ };
15
+
16
+
17
+ context({
18
+ ...sharedConfig,
19
+ outfile: 'dist/index.esm.js',
20
+ platform: 'neutral', // for ESM
21
+ format: 'esm',
22
+ outExtension: { '.js': '.mjs' },
23
+ plugins: [],
24
+ }).then(context => {
25
+ if (process.argv.includes("--watch")) {
26
+ // Enable watch mode
27
+ context.watch()
28
+ console.log(context)
29
+ } else {
30
+ // Build once and exit if not in watch mode
31
+ context.rebuild().then(result => {
32
+ context.dispose()
33
+ })
34
+ }
35
+ }).catch(() => process.exit(1))
36
+
37
+ context({
38
+ ...sharedConfig,
39
+ outfile: 'dist/index.cjs.js',
40
+ platform: 'node', // for ESM
41
+ format: 'cjs',
42
+ outExtension: { '.js': '.cjs' },
43
+ plugins: [],
44
+ }).then(context => {
45
+ if (process.argv.includes("--watch")) {
46
+ // Enable watch mode
47
+ context.watch()
48
+ console.log(context)
49
+ } else {
50
+ // Build once and exit if not in watch mode
51
+ context.rebuild().then(result => {
52
+ context.dispose()
53
+ })
54
+ }
55
+ }).catch(() => process.exit(1))
56
+
57
+
58
+
59
+ new Generator({
60
+ entry: 'src/index.ts',
61
+ output: 'dist/index.d.ts',
62
+ }).generate();
@@ -0,0 +1 @@
1
+ var t=()=>{console.log("testFunc")};export{t as testFunc};
package/index.html ADDED
@@ -0,0 +1,13 @@
1
+ <!DOCTYPE html>
2
+ <html lang="en">
3
+ <head>
4
+ <meta charset="UTF-8" />
5
+ <link rel="icon" type="image/svg+xml" href="/vite.svg" />
6
+ <meta name="viewport" content="width=device-width, initial-scale=1.0" />
7
+ <title>Vite + React + TS</title>
8
+ </head>
9
+ <body>
10
+ <div id="root"></div>
11
+ <script type="module" src="/src/main.tsx"></script>
12
+ </body>
13
+ </html>
package/jest.config.js ADDED
@@ -0,0 +1,18 @@
1
+
2
+ module.exports = {
3
+ preset: 'ts-jest',
4
+ testEnvironment: 'node',
5
+ testMatch: ['<rootDir>/**/__tests__/**/*.spec.ts', "<rootDir>/**/*.test.ts"],
6
+ testPathIgnorePatterns: ['/node_modules/'],
7
+ coverageDirectory: './coverage',
8
+ coveragePathIgnorePatterns: ['node_modules', 'src/database', 'src/test', 'src/types'],
9
+ reporters: ['default', 'jest-junit'],
10
+ globals: { 'ts-jest': { diagnostics: false } },
11
+ transform: {
12
+ '^.+\\.tsx?$': ['ts-jest', {//the content you'd placed at "global"
13
+ babel: true,
14
+ }]
15
+ },
16
+ resolver: require.resolve(`jest-pnp-resolver`)
17
+ };
18
+
package/junit.xml ADDED
@@ -0,0 +1,7 @@
1
+ <?xml version="1.0" encoding="UTF-8"?>
2
+ <testsuites name="jest tests" tests="1" failures="0" errors="0" time="0.782">
3
+ <testsuite name="Button" errors="0" failures="0" skipped="0" timestamp="2023-07-05T06:36:49" time="0.742" tests="1">
4
+ <testcase classname="Button should be defined" name="Button should be defined" time="0">
5
+ </testcase>
6
+ </testsuite>
7
+ </testsuites>
package/package.json ADDED
@@ -0,0 +1,38 @@
1
+ {
2
+ "name": "@shoplflow/base",
3
+ "private": false,
4
+ "version": "0.0.0",
5
+ "type": "module",
6
+ "scripts": {
7
+ "lint": "eslint src --ext ts,tsx --report-unused-disable-directives --max-warnings 0",
8
+ "test": "jest",
9
+ "build": "node build.cjs",
10
+ "develop": "yarn build --watch"
11
+ },
12
+ "main": "dist/index.esm.js",
13
+ "module": "dist/index.cjs.js",
14
+ "types": "dist/index.d.ts",
15
+ "dependencies": {
16
+ "react": "^18.2.0",
17
+ "react-dom": "^18.2.0"
18
+ },
19
+ "devDependencies": {
20
+ "@babel/core": "^7.22.5",
21
+ "@babel/preset-env": "^7.22.5",
22
+ "@babel/preset-typescript": "^7.22.5",
23
+ "@jest/globals": "^29.5.0",
24
+ "@types/jest": "^29.5.2",
25
+ "@types/react": "^18.0.37",
26
+ "@types/react-dom": "^18.0.11",
27
+ "babel-jest": "^29.5.0",
28
+ "esbuild": "^0.18.11",
29
+ "jest": "^29.5.0",
30
+ "jest-junit": "^16.0.0",
31
+ "jest-pnp-resolver": "^1.2.3",
32
+ "npm-dts": "^1.3.12",
33
+ "prop-types": "^15.8.1",
34
+ "ts-jest": "^29.1.0",
35
+ "ts-node": "^10.9.1",
36
+ "typescript": "^5.0.2"
37
+ }
38
+ }
@@ -0,0 +1,7 @@
1
+ import {describe, expect, test} from '@jest/globals';
2
+
3
+ describe('Button', () => {
4
+ test('should be defined', () => {
5
+ expect(true).toBeTruthy();
6
+ });
7
+ });
package/src/index.ts ADDED
@@ -0,0 +1,5 @@
1
+ export type TestFunc = () => void;
2
+
3
+ export const testFunc: TestFunc = () => {
4
+ console.log('testFunc');
5
+ }
package/tsconfig.json ADDED
@@ -0,0 +1,3 @@
1
+ {
2
+ "extends": "../../tsconfig.esbuild.json"
3
+ }