Skip to content

Commit

Permalink
vx: separate dev and prod builds
Browse files Browse the repository at this point in the history
  • Loading branch information
ealush committed Aug 2, 2023
1 parent eee4905 commit ae7581d
Show file tree
Hide file tree
Showing 4 changed files with 68 additions and 48 deletions.
60 changes: 30 additions & 30 deletions packages/vest/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -25,36 +25,6 @@
"vestjs-runtime": "^0.0.1"
},
"exports": {
"./suiteSerializer": {
"production": {
"types": "./types/suiteSerializer.d.ts",
"browser": "./dist/es/suiteSerializer.production.js",
"umd": "./dist/umd/suiteSerializer.production.js",
"import": "./dist/es/suiteSerializer.production.js",
"require": "./dist/cjs/suiteSerializer.production.js",
"node": "./dist/cjs/suiteSerializer.production.js",
"module": "./dist/es/suiteSerializer.production.js",
"default": "./dist/cjs/suiteSerializer.production.js"
},
"development": {
"types": "./types/suiteSerializer.d.ts",
"browser": "./dist/es/suiteSerializer.development.js",
"umd": "./dist/umd/suiteSerializer.development.js",
"import": "./dist/es/suiteSerializer.development.js",
"require": "./dist/cjs/suiteSerializer.development.js",
"node": "./dist/cjs/suiteSerializer.development.js",
"module": "./dist/es/suiteSerializer.development.js",
"default": "./dist/cjs/suiteSerializer.development.js"
},
"types": "./types/suiteSerializer.d.ts",
"browser": "./dist/es/suiteSerializer.production.js",
"umd": "./dist/umd/suiteSerializer.production.js",
"import": "./dist/es/suiteSerializer.production.js",
"require": "./dist/cjs/suiteSerializer.production.js",
"node": "./dist/cjs/suiteSerializer.production.js",
"module": "./dist/es/suiteSerializer.production.js",
"default": "./dist/cjs/suiteSerializer.production.js"
},
"./promisify": {
"production": {
"types": "./types/promisify.d.ts",
Expand Down Expand Up @@ -295,6 +265,36 @@
"module": "./dist/es/classnames.production.js",
"default": "./dist/cjs/classnames.production.js"
},
"./SuiteSerializer": {
"production": {
"types": "./types/SuiteSerializer.d.ts",
"browser": "./dist/es/SuiteSerializer.production.js",
"umd": "./dist/umd/SuiteSerializer.production.js",
"import": "./dist/es/SuiteSerializer.production.js",
"require": "./dist/cjs/SuiteSerializer.production.js",
"node": "./dist/cjs/SuiteSerializer.production.js",
"module": "./dist/es/SuiteSerializer.production.js",
"default": "./dist/cjs/SuiteSerializer.production.js"
},
"development": {
"types": "./types/SuiteSerializer.d.ts",
"browser": "./dist/es/SuiteSerializer.development.js",
"umd": "./dist/umd/SuiteSerializer.development.js",
"import": "./dist/es/SuiteSerializer.development.js",
"require": "./dist/cjs/SuiteSerializer.development.js",
"node": "./dist/cjs/SuiteSerializer.development.js",
"module": "./dist/es/SuiteSerializer.development.js",
"default": "./dist/cjs/SuiteSerializer.development.js"
},
"types": "./types/SuiteSerializer.d.ts",
"browser": "./dist/es/SuiteSerializer.production.js",
"umd": "./dist/umd/SuiteSerializer.production.js",
"import": "./dist/es/SuiteSerializer.production.js",
"require": "./dist/cjs/SuiteSerializer.production.js",
"node": "./dist/cjs/SuiteSerializer.production.js",
"module": "./dist/es/SuiteSerializer.production.js",
"default": "./dist/cjs/SuiteSerializer.production.js"
},
".": {
"development": {
"types": "./types/vest.d.ts",
Expand Down
35 changes: 17 additions & 18 deletions vx/config/rollup/rollup.config.cjs
Original file line number Diff line number Diff line change
Expand Up @@ -23,30 +23,29 @@ module.exports = commandLineArgs => {
const {
[opts.vx_config.VX_ROLLUP_FAST_BUILD]: fastBuild,
[opts.vx_config.VX_ROLLUP_BUILD_ENTRY]: buildEntry,
[opts.vx_config.VX_ROLLUP_ENV]: env,
} = commandLineArgs;

const fast = JSON.parse(fastBuild);

return cleanupConfig(
concatTruthy(opts.env.PRODUCTION, !fast && opts.env.DEVELOPMENT).map(
env => {
const packageName = usePackage();

switch (buildEntry) {
case opts.vx_config.VX_ROLLUP_BUILD_ENTRY_MAIN:
return genBaseConfig({ env, packageName });
case opts.vx_config.VX_ROLLUP_BUILD_ENTRY_EXPORTS:
return genExportsConfig(packageName, env);
default:
throw new Error(
`Invalid build entry: ${buildEntry}. Must be one of: ${[
opts.vx_config.VX_ROLLUP_BUILD_ENTRY_MAIN,
opts.vx_config.VX_ROLLUP_BUILD_ENTRY_EXPORTS,
].join(', ')}`
);
}
concatTruthy(env).map(env => {
const packageName = usePackage();

switch (buildEntry) {
case opts.vx_config.VX_ROLLUP_BUILD_ENTRY_MAIN:
return genBaseConfig({ env, packageName });
case opts.vx_config.VX_ROLLUP_BUILD_ENTRY_EXPORTS:
return genExportsConfig(packageName, env);
default:
throw new Error(
`Invalid build entry: ${buildEntry}. Must be one of: ${[
opts.vx_config.VX_ROLLUP_BUILD_ENTRY_MAIN,
opts.vx_config.VX_ROLLUP_BUILD_ENTRY_EXPORTS,
].join(', ')}`
);
}
)
})
);
};

Expand Down
1 change: 1 addition & 0 deletions vx/opts.js
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@ module.exports = {
VX_ROLLUP_BUILD_ENTRY: 'configbuildEntry',
VX_ROLLUP_BUILD_ENTRY_EXPORTS: 'EXPORTS',
VX_ROLLUP_BUILD_ENTRY_MAIN: 'MAIN',
VX_ROLLUP_ENV: 'configEnv',
VX_ROLLUP_FAST_BUILD: 'configfastBuild',
},
};
20 changes: 20 additions & 0 deletions vx/scripts/build/buildPackage.js
Original file line number Diff line number Diff line change
Expand Up @@ -31,16 +31,34 @@ function buildPackage(options = {}) {
buildRollup({
...baseOptions,
buildEntry: opts.vx_config.VX_ROLLUP_BUILD_ENTRY_MAIN,
env: opts.env.PRODUCTION,
});

if (!options.fastBuild) {
buildRollup({
...baseOptions,
buildEntry: opts.vx_config.VX_ROLLUP_BUILD_ENTRY_MAIN,
env: opts.env.DEVELOPMENT,
});
}

const packageExportsPath = vxPath.packageSrcExports(name);

// BUILD EXPORTS
if (fse.existsSync(packageExportsPath)) {
buildRollup({
...baseOptions,
buildEntry: opts.vx_config.VX_ROLLUP_BUILD_ENTRY_EXPORTS,
env: opts.env.PRODUCTION,
});

if (!options.fastBuild) {
buildRollup({
...baseOptions,
buildEntry: opts.vx_config.VX_ROLLUP_BUILD_ENTRY_EXPORTS,
env: opts.env.DEVELOPMENT,
});
}
}

delete process.env.VX_PACKAGE_NAME;
Expand All @@ -51,12 +69,14 @@ function buildRollup({
format = [],
fastBuild = false,
buildEntry,
env = opts.env.PRODUCTION,
}) {
exec([
`yarn rollup -c`,
vxPath.ROLLUP_CONFIG_PATH,
cliOptions,
format.length && `--format=${format}`,
`--${opts.vx_config.VX_ROLLUP_ENV}=${env}`,
`--${opts.vx_config.VX_ROLLUP_FAST_BUILD}=${fastBuild}`,
`--${opts.vx_config.VX_ROLLUP_BUILD_ENTRY}=${buildEntry}`,
]);
Expand Down

2 comments on commit ae7581d

@vercel
Copy link

@vercel vercel bot commented on ae7581d Aug 2, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Successfully deployed to the following URLs:

vest-next – ./website

vest-next-ealush.vercel.app
vest-next.vercel.app
vest-next-git-latest-ealush.vercel.app
vest-website.vercel.app

@vercel
Copy link

@vercel vercel bot commented on ae7581d Aug 2, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Successfully deployed to the following URLs:

vest – ./website

vest-git-latest-ealush.vercel.app
vest-ealush.vercel.app
vestjs.dev
www.vestjs.dev
vest.vercel.app

Please sign in to comment.