chore: revert some of the universal file stuff for now

This commit is contained in:
blam
2020-12-16 10:36:57 +01:00
parent a04b28ac4b
commit c754b6aa47
10 changed files with 18 additions and 76 deletions
+1 -16
View File
@@ -79,21 +79,6 @@ export const makeConfigs = async (
mainFields.unshift('browser');
}
const commonjsInclude: Array<RegExp | string> = [/node_modules/];
// Purpose of this file is
// to be bridge between
// frontend- and backend-
// plugins' code
const UNIVERSAL_FILE = 'universal.js';
const universalPath = paths.resolveTarget(UNIVERSAL_FILE);
const universalFileExists = fs.existsSync(universalPath);
if (universalFileExists) {
mainFields.push(UNIVERSAL_FILE);
commonjsInclude.push(UNIVERSAL_FILE);
}
configs.push({
input: 'src/index.ts',
output,
@@ -105,7 +90,7 @@ export const makeConfigs = async (
}),
resolve({ mainFields }),
commonjs({
include: commonjsInclude,
include: /node_modules/,
exclude: [/\/[^/]+\.(?:stories|test)\.[^/]+$/],
}),
postcss(),
+9 -21
View File
@@ -68,27 +68,6 @@ class PackageJsonHandler {
await this.syncDependencies('devDependencies');
}
private async syncFiles() {
const hasUniversalFile = this.targetPkg.files.includes('universal.js');
const hasConfigTypeScriptFile =
typeof this.targetPkg.configSchema === 'string';
if (hasUniversalFile || hasConfigTypeScriptFile) {
const files = [...this.pkg.files];
if (hasUniversalFile) {
files.push('universal.js');
}
if (hasConfigTypeScriptFile) {
files.push(this.targetPkg.configSchema);
}
await this.syncField('files', { files });
} else {
await this.syncField('files');
}
}
// Make sure a field inside package.json is in sync. This mutates the targetObj and writes package.json on change.
private async syncField(
fieldName: string,
@@ -126,6 +105,15 @@ class PackageJsonHandler {
}
}
private async syncFiles() {
if (typeof this.targetPkg.configSchema === 'string') {
const files = [...this.pkg.files, this.targetPkg.configSchema];
await this.syncField('files', { files });
} else {
await this.syncField('files');
}
}
private async syncScripts() {
const pkgScripts = this.pkg.scripts;
const targetScripts = (this.targetPkg.scripts =