@unisphere/cli 1.44.2 → 1.44.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/bundler/package/rollup.js +2 -2
- package/bundler/runtime/rollup.js +23 -19
- package/package.json +1 -1
|
@@ -87,9 +87,9 @@ module.exports = (unisphereConfig) => {
|
|
|
87
87
|
const projectJson = JSON.parse(fs.readFileSync(projectJsonPath, 'utf8'));
|
|
88
88
|
const sourcePath = projectJson.sourceRoot.replace(/\/src$/, '').split('/');
|
|
89
89
|
if (sourcePath.length !== 3 || sourcePath[0] !== 'unisphere' || sourcePath[1] !== 'packages') {
|
|
90
|
-
throw new Error('sourcePath follow pattern unisphere/packages/<package-name>')
|
|
90
|
+
throw new Error('sourcePath must follow pattern unisphere/packages/<package-name>')
|
|
91
91
|
}
|
|
92
|
-
const outputPath =
|
|
92
|
+
const outputPath = path.join('..', '..', '..', 'dist', ...sourcePath);
|
|
93
93
|
|
|
94
94
|
|
|
95
95
|
return withUnisphere(withNx(
|
|
@@ -56,8 +56,8 @@ const getWithNx = (unisphereConfig) => {
|
|
|
56
56
|
|
|
57
57
|
const relativeSourcePath = path.relative(unisphereConfig.cwd, unisphereConfig.workspaceConfiguration.cwd);
|
|
58
58
|
|
|
59
|
-
const outputPath =
|
|
60
|
-
|
|
59
|
+
const outputPath = path.join(relativeSourcePath, 'dist', ...unisphereConfig.sourcePath);
|
|
60
|
+
|
|
61
61
|
const firstArgument = {
|
|
62
62
|
main: './src/index.ts',
|
|
63
63
|
outputPath,
|
|
@@ -80,10 +80,10 @@ const getWithNx = (unisphereConfig) => {
|
|
|
80
80
|
}),
|
|
81
81
|
]
|
|
82
82
|
}
|
|
83
|
-
|
|
83
|
+
|
|
84
84
|
if (isDeployingRuntime) {
|
|
85
85
|
const unispherePackagesDistList = getUnispherePackagesDistList(unisphereConfig.workspaceConfiguration.cwd);
|
|
86
|
-
|
|
86
|
+
|
|
87
87
|
secondArgument.unisphere = getUnisphereTSInterceptorsConfig(unispherePackagesDistList);
|
|
88
88
|
return withUnisphere(withNx(
|
|
89
89
|
firstArgument,
|
|
@@ -99,8 +99,12 @@ const getWithNx = (unisphereConfig) => {
|
|
|
99
99
|
|
|
100
100
|
function getUnispherePackagesDistList(cwd) {
|
|
101
101
|
|
|
102
|
-
|
|
103
|
-
|
|
102
|
+
let folderPattern = path.join(cwd, 'dist', 'unisphere', 'packages', '*');
|
|
103
|
+
|
|
104
|
+
if (process.platform === 'win32') {
|
|
105
|
+
console.log('[unisphere] running on Windows');
|
|
106
|
+
folderPattern = folderPattern.replace(/\//g, '\\');
|
|
107
|
+
}
|
|
104
108
|
console.log('[unisphere] looking for packages in', folderPattern);
|
|
105
109
|
const folderPaths = glob.sync(folderPattern);
|
|
106
110
|
const result = [];
|
|
@@ -125,24 +129,24 @@ function getUnispherePackagesDistList(cwd) {
|
|
|
125
129
|
}
|
|
126
130
|
|
|
127
131
|
const withUnisphere = (rollupConfig, unispherePackagesDistList) => {
|
|
128
|
-
|
|
132
|
+
|
|
129
133
|
console.log('[unisphere] removing unisphere config used to monkey patch @nw/rollup');
|
|
130
134
|
delete rollupConfig.unisphere;
|
|
131
|
-
|
|
135
|
+
|
|
132
136
|
rollupConfig.onwarn = (warning, warn) => {
|
|
133
137
|
if (warning.code === 'THIS_IS_UNDEFINED') return;
|
|
134
138
|
if (warning.code === 'MODULE_LEVEL_DIRECTIVE') return;
|
|
135
139
|
warn(warning); // this requires Rollup 0.46
|
|
136
140
|
};
|
|
137
|
-
|
|
141
|
+
|
|
138
142
|
rollupConfig.external = [];
|
|
139
|
-
|
|
143
|
+
|
|
140
144
|
if (isProduction) {
|
|
141
145
|
rollupConfig.output[0].entryFileNames = 'index.esm.js'
|
|
142
146
|
} else {
|
|
143
147
|
rollupConfig.output[0].entryFileNames = 'index.dev.esm.js'
|
|
144
148
|
}
|
|
145
|
-
|
|
149
|
+
|
|
146
150
|
rollupConfig.plugins.push(
|
|
147
151
|
alias({
|
|
148
152
|
entries: unispherePackagesDistList.map(item => {
|
|
@@ -162,24 +166,24 @@ const withUnisphere = (rollupConfig, unispherePackagesDistList) => {
|
|
|
162
166
|
}),
|
|
163
167
|
isProduction ? terser() : undefined
|
|
164
168
|
);
|
|
165
|
-
|
|
166
|
-
|
|
169
|
+
|
|
170
|
+
|
|
167
171
|
return rollupConfig;
|
|
168
172
|
};
|
|
169
|
-
|
|
170
|
-
|
|
173
|
+
|
|
174
|
+
|
|
171
175
|
|
|
172
176
|
|
|
173
177
|
module.exports = (unisphereConfig) => {
|
|
174
178
|
|
|
175
179
|
console.log('[unisphere] unisphere rollup args before stripping', unisphereConfig);
|
|
176
|
-
|
|
180
|
+
|
|
177
181
|
const workspaceConfiguration = getUnisphereWorkspaceFile(unisphereConfig.cwd);
|
|
178
182
|
|
|
179
183
|
if (!workspaceConfiguration) {
|
|
180
184
|
throw new Error('the library must be run from the root of the unisphere workspace');
|
|
181
185
|
}
|
|
182
|
-
|
|
186
|
+
|
|
183
187
|
const projectJsonPath = path.join(unisphereConfig.cwd, 'project.json');
|
|
184
188
|
|
|
185
189
|
const projectJson = JSON.parse(fs.readFileSync(projectJsonPath, 'utf8'));
|
|
@@ -190,7 +194,7 @@ module.exports = (unisphereConfig) => {
|
|
|
190
194
|
if (!pathCheck || sourcePath[0] !== 'unisphere' || sourcePath[1] !== expectedType) {
|
|
191
195
|
throw new Error(`sourcePath must follow pattern unisphere/${expectedType}/<runtime-name>, got ${sourcePath.join('/')}`)
|
|
192
196
|
}
|
|
193
|
-
|
|
197
|
+
|
|
194
198
|
// todo can improve code readability by moving the calculation of the 'outputPath' here instead of in getWithNx
|
|
195
199
|
return getWithNx(
|
|
196
200
|
{
|
|
@@ -199,4 +203,4 @@ module.exports = (unisphereConfig) => {
|
|
|
199
203
|
sourcePath
|
|
200
204
|
}
|
|
201
205
|
);
|
|
202
|
-
}
|
|
206
|
+
}
|