📦 sdk: fix nextjs package
This commit is contained in:
@@ -12,9 +12,9 @@
|
||||
"@openpanel/web": "workspace:*"
|
||||
},
|
||||
"peerDependencies": {
|
||||
"next": "^14.0.0",
|
||||
"react": "^18.2.0",
|
||||
"react-dom": "^18.2.0"
|
||||
"next": "^12.0.0 || ^13.0.0 || ^14.0.0",
|
||||
"react": "^16.8.0 || ^17.0.0 || ^18.0.0",
|
||||
"react-dom": "^16.8.0 || ^17.0.0 || ^18.0.0"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@openpanel/eslint-config": "workspace:*",
|
||||
|
||||
@@ -5,5 +5,5 @@ import config from '@openpanel/tsconfig/tsup.config.json' assert { type: 'json'
|
||||
export default defineConfig({
|
||||
...(config as any),
|
||||
entry: ['index.tsx'],
|
||||
format: ['cjs', 'esm'],
|
||||
external: ['react', 'next'],
|
||||
});
|
||||
|
||||
11
sh/move-sdks-to-examples
Executable file
11
sh/move-sdks-to-examples
Executable file
@@ -0,0 +1,11 @@
|
||||
#!/bin/bash
|
||||
|
||||
# nextjs-13-pages
|
||||
rm -rf ../openpanel-examples/nextjs-13-pages/node_modules/@openpanel/nextjs && cp -R packages/sdks/nextjs ../openpanel-examples/nextjs-13-pages/node_modules/@openpanel/nextjs
|
||||
rm -rf ../openpanel-examples/nextjs-13-pages/node_modules/@openpanel/web && cp -R packages/sdks/nextjs ../openpanel-examples/nextjs-13-pages/node_modules/@openpanel/web
|
||||
# nextjs-app-dir
|
||||
rm -rf ../openpanel-examples/nextjs-app-dir/node_modules/@openpanel/nextjs && cp -R packages/sdks/nextjs ../openpanel-examples/nextjs-app-dir/node_modules/@openpanel/nextjs
|
||||
rm -rf ../openpanel-examples/nextjs-app-dir/node_modules/@openpanel/web && cp -R packages/sdks/nextjs ../openpanel-examples/nextjs-app-dir/node_modules/@openpanel/web
|
||||
# expo-app
|
||||
rm -rf ../openpanel-examples/expo-app/node_modules/@openpanel/react-native && cp -R packages/sdks/react-native ../openpanel-examples/expo-app/node_modules/@openpanel/react-native
|
||||
rm -rf ../openpanel-examples/expo-app/node_modules/@openpanel/sdk && cp -R packages/sdks/sdk ../openpanel-examples/expo-app/node_modules/@openpanel/sdk
|
||||
@@ -40,16 +40,19 @@ function checkUncommittedChanges() {
|
||||
}
|
||||
|
||||
function main() {
|
||||
checkUncommittedChanges();
|
||||
|
||||
const args = arg({
|
||||
// Types
|
||||
'--version': String,
|
||||
'--test': Boolean,
|
||||
'--skip-git': Boolean,
|
||||
// Aliases
|
||||
'-v': '--version',
|
||||
});
|
||||
|
||||
if (!args['--skip-git']) {
|
||||
checkUncommittedChanges();
|
||||
}
|
||||
|
||||
const version = args['--version'];
|
||||
const test = args['--test'];
|
||||
|
||||
@@ -57,22 +60,27 @@ function main() {
|
||||
return console.error('Version is not valid');
|
||||
}
|
||||
|
||||
const properties = {
|
||||
private: false,
|
||||
version,
|
||||
type: 'module',
|
||||
main: './dist/index.js',
|
||||
module: './dist/index.mjs',
|
||||
types: './dist/index.d.ts',
|
||||
files: ['dist'],
|
||||
exports: {
|
||||
import: './dist/index.js',
|
||||
require: './dist/index.cjs',
|
||||
},
|
||||
};
|
||||
|
||||
try {
|
||||
for (const name of sdkPackages) {
|
||||
const properties: Record<string, unknown> = {
|
||||
private: false,
|
||||
version,
|
||||
type: 'module',
|
||||
main: './dist/index.js',
|
||||
module: './dist/index.mjs',
|
||||
types: './dist/index.d.ts',
|
||||
files: ['dist'],
|
||||
exports: {
|
||||
import: './dist/index.js',
|
||||
require: './dist/index.cjs',
|
||||
},
|
||||
};
|
||||
|
||||
// Not sure if I even should have type: module for any sdk
|
||||
if (name === 'nextjs') {
|
||||
delete properties.type;
|
||||
}
|
||||
|
||||
const pkgJson = require(
|
||||
workspacePath(`./packages/sdks/${name}/package.json`)
|
||||
);
|
||||
|
||||
Reference in New Issue
Block a user