mirror of
https://github.com/ianstormtaylor/slate.git
synced 2025-08-19 05:31:56 +02:00
Bugfix/fix bundles (#3673)
* fix index.js main bundles to be commonjs instead of modules * Change rm -rf to rimraf to be cross os compatible * add rimraf as dependency Co-authored-by: damareyoh <chackerman@wsu.edu>
This commit is contained in:
@@ -22,6 +22,7 @@ function configure(pkg, env, target) {
|
||||
const isProd = env === 'production'
|
||||
const isUmd = target === 'umd'
|
||||
const isModule = target === 'module'
|
||||
const isCommonJs = target === 'cjs'
|
||||
const input = `packages/${pkg.name}/src/index.ts`
|
||||
const deps = []
|
||||
.concat(pkg.dependencies ? Object.keys(pkg.dependencies) : [])
|
||||
@@ -103,7 +104,7 @@ function configure(pkg, env, target) {
|
||||
],
|
||||
modules: false,
|
||||
targets: {
|
||||
esmodules: true,
|
||||
esmodules: isModule,
|
||||
},
|
||||
},
|
||||
],
|
||||
@@ -116,7 +117,7 @@ function configure(pkg, env, target) {
|
||||
? {}
|
||||
: {
|
||||
regenerator: false,
|
||||
useESModules: true,
|
||||
useESModules: isModule,
|
||||
},
|
||||
],
|
||||
'@babel/plugin-proposal-class-properties',
|
||||
@@ -147,6 +148,28 @@ function configure(pkg, env, target) {
|
||||
}
|
||||
}
|
||||
|
||||
if (isCommonJs) {
|
||||
return {
|
||||
plugins,
|
||||
input,
|
||||
onwarn,
|
||||
output: [
|
||||
{
|
||||
file: `packages/${pkg.name}/${pkg.main}`,
|
||||
format: 'cjs',
|
||||
exports: 'named',
|
||||
sourcemap: true,
|
||||
},
|
||||
],
|
||||
// We need to explicitly state which modules are external, meaning that
|
||||
// they are present at runtime. In the case of non-UMD configs, this means
|
||||
// all non-Slate packages.
|
||||
external: id => {
|
||||
return !!deps.find(dep => dep === id || id.startsWith(`${dep}/`))
|
||||
},
|
||||
}
|
||||
}
|
||||
|
||||
if (isModule) {
|
||||
return {
|
||||
plugins,
|
||||
@@ -157,13 +180,7 @@ function configure(pkg, env, target) {
|
||||
file: `packages/${pkg.name}/${pkg.module}`,
|
||||
format: 'es',
|
||||
sourcemap: true,
|
||||
},
|
||||
{
|
||||
file: `packages/${pkg.name}/${pkg.main}`,
|
||||
format: 'cjs',
|
||||
exports: 'named',
|
||||
sourcemap: true,
|
||||
},
|
||||
}
|
||||
],
|
||||
// We need to explicitly state which modules are external, meaning that
|
||||
// they are present at runtime. In the case of non-UMD configs, this means
|
||||
@@ -182,6 +199,7 @@ function configure(pkg, env, target) {
|
||||
function factory(pkg, options = {}) {
|
||||
const isProd = process.env.NODE_ENV === 'production'
|
||||
return [
|
||||
configure(pkg, 'development', 'cjs', options),
|
||||
configure(pkg, 'development', 'module', options),
|
||||
isProd && configure(pkg, 'development', 'umd', options),
|
||||
isProd && configure(pkg, 'production', 'umd', options),
|
||||
|
@@ -8,7 +8,7 @@
|
||||
"build": "yarn build:rollup && yarn build:next",
|
||||
"build:next": "cd ./site && next build && next export",
|
||||
"build:rollup": "rollup --config ./config/rollup/rollup.config.js",
|
||||
"clean": "rm -rf ./node_modules ./packages/*/{dist,lib,node_modules} ./site/{.next,out}",
|
||||
"clean": "rimraf ./node_modules ./packages/*/{dist,lib,node_modules} ./site/{.next,out}",
|
||||
"fix": "yarn fix:prettier && yarn fix:eslint",
|
||||
"fix:eslint": "yarn lint:eslint --fix",
|
||||
"fix:prettier": "yarn lint:prettier --write",
|
||||
@@ -69,6 +69,7 @@
|
||||
"react-error-boundary": "^1.2.5",
|
||||
"react-router-dom": "^5.1.2",
|
||||
"react-values": "^0.3.0",
|
||||
"rimraf": "^3.0.2",
|
||||
"rollup": "^1.27.5",
|
||||
"rollup-plugin-babel": "^4.3.3",
|
||||
"rollup-plugin-commonjs": "^10.1.0",
|
||||
|
@@ -9629,6 +9629,13 @@ rimraf@2.6.3:
|
||||
dependencies:
|
||||
glob "^7.1.3"
|
||||
|
||||
rimraf@^3.0.2:
|
||||
version "3.0.2"
|
||||
resolved "https://registry.yarnpkg.com/rimraf/-/rimraf-3.0.2.tgz#f1a5402ba6220ad52cc1282bac1ae3aa49fd061a"
|
||||
integrity sha512-JZkJMZkAGFFPP2YqXZXPbMlMBgsxzE8ILs4lMIX/2o0L9UBw9O/Y3o6wFw/i9YLapcUJWwqbi3kdxIPdC62TIA==
|
||||
dependencies:
|
||||
glob "^7.1.3"
|
||||
|
||||
ripemd160@^2.0.0, ripemd160@^2.0.1:
|
||||
version "2.0.2"
|
||||
resolved "https://registry.yarnpkg.com/ripemd160/-/ripemd160-2.0.2.tgz#a1c1a6f624751577ba5d07914cbc92850585890c"
|
||||
|
Reference in New Issue
Block a user