mirror of
https://github.com/vercel/next.js.git
synced 2026-09-20 02:25:18 +08:00
2ae9f1a3a5
Libraries that want to support Next.js without specific public adaptors must use dynamic requires and other non-standard tricks to conditionally load Next.js specific behavior. To simplify this we are adding a condition to Next.js so that package authors can load Next.js specific versions of code publicly (through export maps) and privately (through import maps). The condition is added when cacheComponents is enabled. This will allow libraries to target modern Next.js conditionally without publishing new majors with a new floor version for optional peer dependencies on Next.js. In the future this will be the only mode for Next.js and the condition will always be present The condition is currently only implemented for bundled code. We want to support this for externals too but it is tricky because determining the right condition requires running Node.js first and I want to be careful about adding any process indirection that slows down cold start. This will be addressed in a future update. --------- Co-authored-by: Sebastian Sebbie Silbermann <sebastian.silbermann@vercel.com>
40 lines
884 B
Bash
Executable File
40 lines
884 B
Bash
Executable File
#!/usr/bin/env bash
|
|
|
|
START_DIR=$PWD
|
|
# gets last argument which should be the project dir
|
|
for PROJECT_DIR in $@;do :;done
|
|
|
|
if [ -z $PROJECT_DIR ];then
|
|
echo "No project directory provided, exiting..."
|
|
exit 1;
|
|
fi;
|
|
|
|
if [ ! -d $PROJECT_DIR ];then
|
|
echo "Invalid project directory provided, exiting..."
|
|
exit 1;
|
|
fi;
|
|
|
|
if [ $PROJECT_DIR == $PWD ] || [ "$PROJECT_DIR" == "." ];then
|
|
echo "Project directory can not be root, exiting..."
|
|
exit 1;
|
|
fi;
|
|
|
|
CONFLICTING_DEPS=("react" "react-dom" "styled-jsx" "next")
|
|
|
|
for dep in ${CONFLICTING_DEPS[@]};do
|
|
if [ -d "$PROJECT_DIR/node_modules/$dep" ];then
|
|
HAS_CONFLICTING_DEP="yup"
|
|
fi;
|
|
done
|
|
|
|
if [ ! -z $HAS_CONFLICTING_DEP ] || [ ! -d "$PROJECT_DIR/node_modules" ];then
|
|
cd $PROJECT_DIR
|
|
pnpm i --ignore-workspace --no-lockfile
|
|
for dep in ${CONFLICTING_DEPS[@]};do
|
|
rm -rf node_modules/$dep
|
|
done
|
|
fi
|
|
|
|
cd $START_DIR
|
|
pnpm next $@
|