@vitus-labs/tools-rollup 1.2.0 → 1.3.0
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/lib/bin/run-build.js +0 -0
- package/lib/bin/run-watch.js +1 -0
- package/lib/bin/run-watch.js.map +1 -1
- package/lib/rollup/config.js +10 -8
- package/lib/rollup/config.js.map +1 -1
- package/lib/rollup/createBuildPipeline.js +23 -19
- package/lib/rollup/createBuildPipeline.js.map +1 -1
- package/lib/types/bin/run-watch.d.ts +1 -3
- package/lib/types/rollup/config.d.ts +2 -2
- package/package.json +13 -6
- package/src/rollup/config.ts +10 -8
- package/src/rollup/createBuildPipeline.ts +24 -19
- package/tsconfig.json +1 -1
package/lib/bin/run-build.js
CHANGED
|
File without changes
|
package/lib/bin/run-watch.js
CHANGED
package/lib/bin/run-watch.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"run-watch.js","sourceRoot":"","sources":["../../src/bin/run-watch.ts"],"names":[],"mappings":";AACA,MAAM,MAAM,GAAG,OAAO,CAAC,QAAQ,CAAC,CAAA;AAEhC,MAAM,YAAY,GAAG,EAAE,CAAA;AACvB,MAAM,OAAO,GAAG,MAAM,CAAC,KAAK,CAAC,YAAY,CAAC,CAAA;AAE1C,OAAO,CAAC,EAAE,CAAC,OAAO,EAAE,CAAC,KAAK,EAAE,EAAE;IAC5B,4BAA4B;IAC5B,+CAA+C;IAC/C,iDAAiD;IACjD,8CAA8C;IAC9C,iDAAiD;IACjD,uDAAuD;AACzD,CAAC,CAAC,CAAA
|
|
1
|
+
{"version":3,"file":"run-watch.js","sourceRoot":"","sources":["../../src/bin/run-watch.ts"],"names":[],"mappings":";AACA,MAAM,MAAM,GAAG,OAAO,CAAC,QAAQ,CAAC,CAAA;AAEhC,MAAM,YAAY,GAAG,EAAE,CAAA;AACvB,MAAM,OAAO,GAAG,MAAM,CAAC,KAAK,CAAC,YAAY,CAAC,CAAA;AAE1C,OAAO,CAAC,EAAE,CAAC,OAAO,EAAE,CAAC,KAAK,EAAE,EAAE;IAC5B,4BAA4B;IAC5B,+CAA+C;IAC/C,iDAAiD;IACjD,8CAA8C;IAC9C,iDAAiD;IACjD,uDAAuD;AACzD,CAAC,CAAC,CAAA;;AAEF,gBAAgB;AAChB,kBAAkB"}
|
package/lib/rollup/config.js
CHANGED
|
@@ -19,7 +19,7 @@ const defineExtensions = (platform) => {
|
|
|
19
19
|
}
|
|
20
20
|
return platformExtensions.concat(CONFIG.extensions);
|
|
21
21
|
};
|
|
22
|
-
const loadPlugins = ({ env, platform,
|
|
22
|
+
const loadPlugins = ({ env, platform, file, typesFilePath }) => {
|
|
23
23
|
const extensions = defineExtensions(platform);
|
|
24
24
|
const plugins = [nodeResolve({ extensions, browser: platform === 'browser' })];
|
|
25
25
|
if (CONFIG.typescript) {
|
|
@@ -31,6 +31,8 @@ const loadPlugins = ({ env, platform, types, file }) => {
|
|
|
31
31
|
tsconfigDefaults: {
|
|
32
32
|
exclude: CONFIG.exclude,
|
|
33
33
|
include: CONFIG.include,
|
|
34
|
+
declarationMap: false,
|
|
35
|
+
declaration: false,
|
|
34
36
|
compilerOptions: {
|
|
35
37
|
types: ['@vitus-labs/tools-rollup'],
|
|
36
38
|
plugins: [
|
|
@@ -43,13 +45,13 @@ const loadPlugins = ({ env, platform, types, file }) => {
|
|
|
43
45
|
},
|
|
44
46
|
},
|
|
45
47
|
};
|
|
46
|
-
if (
|
|
47
|
-
tsConfig.tsconfigDefaults.compilerOptions.declarationMap =
|
|
48
|
-
tsConfig.tsconfigDefaults.compilerOptions.declaration =
|
|
48
|
+
if (typesFilePath) {
|
|
49
|
+
tsConfig.tsconfigDefaults.compilerOptions.declarationMap = true;
|
|
50
|
+
tsConfig.tsconfigDefaults.compilerOptions.declaration = true;
|
|
49
51
|
tsConfig.tsconfigDefaults.compilerOptions.declarationDir = CONFIG.typesDir;
|
|
50
52
|
}
|
|
51
53
|
plugins.push(typescript(tsConfig));
|
|
52
|
-
if (
|
|
54
|
+
if (typesFilePath) {
|
|
53
55
|
plugins.push(apiExtractor({
|
|
54
56
|
cleanUpRollup: true,
|
|
55
57
|
configuration: {
|
|
@@ -61,7 +63,7 @@ const loadPlugins = ({ env, platform, types, file }) => {
|
|
|
61
63
|
},
|
|
62
64
|
dtsRollup: {
|
|
63
65
|
enabled: true,
|
|
64
|
-
untrimmedFilePath: `<projectFolder>${
|
|
66
|
+
untrimmedFilePath: `<projectFolder>${typesFilePath}`,
|
|
65
67
|
},
|
|
66
68
|
},
|
|
67
69
|
}));
|
|
@@ -101,8 +103,8 @@ const loadPlugins = ({ env, platform, types, file }) => {
|
|
|
101
103
|
}
|
|
102
104
|
return plugins;
|
|
103
105
|
};
|
|
104
|
-
const rollupConfig = ({ file, format, env,
|
|
105
|
-
const plugins = loadPlugins({ file, env,
|
|
106
|
+
const rollupConfig = ({ file, format, env, typesFilePath, platform, }) => {
|
|
107
|
+
const plugins = loadPlugins({ file, env, typesFilePath, platform });
|
|
106
108
|
const buildOutput = {
|
|
107
109
|
makeAbsoluteExternalsRelative: true,
|
|
108
110
|
preserveEntrySignatures: 'strict',
|
package/lib/rollup/config.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"config.js","sourceRoot":"","sources":["../../src/rollup/config.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,MAAM,aAAa,CAAA;AAC3C,OAAO,UAAU,MAAM,2BAA2B,CAAA;AAClD,OAAO,EAAE,YAAY,EAAE,MAAM,6BAA6B,CAAA;AAC1D,OAAO,EAAE,WAAW,EAAE,MAAM,6BAA6B,CAAA;AACzD,OAAO,QAAQ,MAAM,wBAAwB,CAAA;AAC7C,OAAO,EAAE,UAAU,EAAE,MAAM,0BAA0B,CAAA;AACrD,OAAO,OAAO,MAAM,wBAAwB,CAAA;AAC5C,OAAO,MAAM,MAAM,uBAAuB,CAAA;AAC1C,OAAO,EAAE,WAAW,EAAE,MAAM,w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ilePath = PKG?.exports?.types || PKG.types || PKG.typings;
|
|
4
|
+
const hasDifferentNativeBuild = () => {
|
|
5
|
+
return PKG['react-native'] !== PKG.module;
|
|
6
|
+
};
|
|
6
7
|
const hasDifferentBrowserBuild = (type) => {
|
|
7
8
|
if (!PKG.browser)
|
|
8
9
|
return false;
|
|
@@ -12,9 +13,9 @@ const hasDifferentBrowserBuild = (type) => {
|
|
|
12
13
|
return source !== PKG[type] && source !== output;
|
|
13
14
|
});
|
|
14
15
|
};
|
|
15
|
-
const
|
|
16
|
+
const BUILD_VARIANTS = {
|
|
16
17
|
main: {
|
|
17
|
-
format:
|
|
18
|
+
format: isESModuleOnly ? 'es' : 'cjs',
|
|
18
19
|
env: 'development',
|
|
19
20
|
platform: 'universal',
|
|
20
21
|
},
|
|
@@ -39,7 +40,7 @@ const getExportsOptions = () => {
|
|
|
39
40
|
return [
|
|
40
41
|
{
|
|
41
42
|
file: PKG.exports,
|
|
42
|
-
...
|
|
43
|
+
...BUILD_VARIANTS.module,
|
|
43
44
|
},
|
|
44
45
|
];
|
|
45
46
|
}
|
|
@@ -48,26 +49,26 @@ const getExportsOptions = () => {
|
|
|
48
49
|
if (exportsOptions.import) {
|
|
49
50
|
result.push({
|
|
50
51
|
file: exportsOptions.import,
|
|
51
|
-
...
|
|
52
|
+
...BUILD_VARIANTS.module,
|
|
52
53
|
});
|
|
53
54
|
}
|
|
54
55
|
if (exportsOptions.require) {
|
|
55
56
|
result.push({
|
|
56
57
|
file: exportsOptions.require,
|
|
57
|
-
...
|
|
58
|
+
...BUILD_VARIANTS.main,
|
|
58
59
|
});
|
|
59
60
|
}
|
|
60
61
|
if (exportsOptions.node) {
|
|
61
62
|
result.push({
|
|
62
63
|
file: exportsOptions.node,
|
|
63
|
-
...
|
|
64
|
+
...BUILD_VARIANTS.module,
|
|
64
65
|
platform: 'node',
|
|
65
66
|
});
|
|
66
67
|
}
|
|
67
68
|
if (exportsOptions.default) {
|
|
68
69
|
result.push({
|
|
69
70
|
file: exportsOptions.default,
|
|
70
|
-
...
|
|
71
|
+
...BUILD_VARIANTS.module,
|
|
71
72
|
});
|
|
72
73
|
}
|
|
73
74
|
return result;
|
|
@@ -76,19 +77,20 @@ const getExportsOptions = () => {
|
|
|
76
77
|
};
|
|
77
78
|
const createBasicBuildVariants = () => {
|
|
78
79
|
let result = [];
|
|
79
|
-
if (
|
|
80
|
+
if (isESModuleOnly)
|
|
80
81
|
result = [...getExportsOptions()];
|
|
81
|
-
Object.keys(
|
|
82
|
+
Object.keys(BUILD_VARIANTS).forEach((key) => {
|
|
82
83
|
const PKGOutDir = PKG[key];
|
|
83
84
|
if (PKGOutDir) {
|
|
84
85
|
const hasBrowserBuild = hasDifferentBrowserBuild(key);
|
|
86
|
+
const hasNativeBuild = hasDifferentNativeBuild();
|
|
85
87
|
// create a helper function for adding a build variant to an array
|
|
86
88
|
const add = (props = {}) => {
|
|
87
|
-
result.push({ ...
|
|
89
|
+
result.push({ ...BUILD_VARIANTS[key], file: PKGOutDir, ...props });
|
|
88
90
|
};
|
|
89
91
|
if (key === 'react-native') {
|
|
90
92
|
// add a separate RN build only if output path differs from module path
|
|
91
|
-
if (
|
|
93
|
+
if (hasNativeBuild) {
|
|
92
94
|
add();
|
|
93
95
|
}
|
|
94
96
|
}
|
|
@@ -111,10 +113,10 @@ const createBrowserBuildVariants = () => {
|
|
|
111
113
|
Object.entries(PKG.browser).forEach(([key, value]) => {
|
|
112
114
|
const source = key.substring(2); // strip './' from the beginning of path
|
|
113
115
|
const output = value.substring(2); // strip './' from the beginning of path
|
|
114
|
-
Object.keys(
|
|
116
|
+
Object.keys(BUILD_VARIANTS).forEach((item) => {
|
|
115
117
|
if (PKG[item] === source && source !== output) {
|
|
116
118
|
result.push({
|
|
117
|
-
...
|
|
119
|
+
...BUILD_VARIANTS[item],
|
|
118
120
|
file: output,
|
|
119
121
|
platform: 'browser',
|
|
120
122
|
});
|
|
@@ -129,7 +131,9 @@ const createBuildPipeline = () => {
|
|
|
129
131
|
...createBrowserBuildVariants(),
|
|
130
132
|
];
|
|
131
133
|
// add generate typings for the first bundle only
|
|
132
|
-
|
|
134
|
+
if (!!typesFilePath) {
|
|
135
|
+
result[0] = { ...result[0], typesFilePath };
|
|
136
|
+
}
|
|
133
137
|
return result;
|
|
134
138
|
};
|
|
135
139
|
export default createBuildPipeline;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"createBuildPipeline.js","sourceRoot":"","sources":["../../src/rollup/createBuildPipeline.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,GAAG,EAAE,MAAM,
|
|
1
|
+
{"version":3,"file":"createBuildPipeline.js","sourceRoot":"","sources":["../../src/rollup/createBuildPipeline.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,GAAG,EAAE,MAAM,oBAAoB,CAAA;AAExC,MAAM,cAAc,GAAG,GAAG,CAAC,IAAI,KAAK,QAAQ,CAAA;AAC5C,MAAM,aAAa,GAAG,GAAG,EAAE,OAAO,EAAE,KAAK,IAAI,GAAG,CAAC,KAAK,IAAI,GAAG,CAAC,OAAO,CAAA;AAErE,MAAM,uBAAuB,GAAG,GAAG,EAAE;IACnC,OAAO,GAAG,CAAC,cAAc,CAAC,KAAK,GAAG,CAAC,MAAM,CAAA;AAC3C,CAAC,CAAA;AAED,MAAM,wBAAwB,GAAG,CAAC,IAAI,EAAE,EAAE;IACxC,IAAI,CAAC,GAAG,CAAC,OAAO;QAAE,OAAO,KAAK,CAAA;IAE9B,OAAO,MAAM,CAAC,OAAO,CAAC,GAAG,CAAC,OAAO,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,GAAG,EAAE,KAAK,CAAmB,EAAE,EAAE;QACzE,MAAM,MAAM,GAAG,GAAG,CAAC,SAAS,CAAC,CAAC,CAAC,CAAA;QAC/B,MAAM,MAAM,GAAG,KAAK,CAAC,SAAS,CAAC,CAAC,CAAC,CAAA;QAEjC,OAAO,MAAM,KAAK,GAAG,CAAC,IAAI,CAAC,IAAI,MAAM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C,CAAC,CAAC,EAAE,aAAa,EAAE,CAAA;KAC5C;IAED,OAAO,MAAM,CAAA;AACf,CAAC,CAAA;AAED,eAAe,mBAAmB,CAAA"}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
declare const rollupConfig: ({ file, format, env,
|
|
1
|
+
declare const rollupConfig: ({ file, format, env, typesFilePath, platform, }: Record<string, any>) => {
|
|
2
2
|
makeAbsoluteExternalsRelative: boolean;
|
|
3
3
|
preserveEntrySignatures: string;
|
|
4
4
|
input: any;
|
|
@@ -17,6 +17,6 @@ declare const rollupConfig: ({ file, format, env, types, platform, }: Record<str
|
|
|
17
17
|
systemNullSetters: boolean;
|
|
18
18
|
};
|
|
19
19
|
external: any[];
|
|
20
|
-
plugins: import("rollup").Plugin[];
|
|
20
|
+
plugins: import("rollup").Plugin<any>[];
|
|
21
21
|
};
|
|
22
22
|
export default rollupConfig;
|
package/package.json
CHANGED
|
@@ -1,14 +1,21 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@vitus-labs/tools-rollup",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.3.0",
|
|
4
4
|
"license": "MIT",
|
|
5
5
|
"author": "Vit Bokisch <vit@bokisch.com>",
|
|
6
6
|
"maintainers": [
|
|
7
7
|
"Vit Bokisch <vit@bokisch.com>"
|
|
8
8
|
],
|
|
9
9
|
"type": "module",
|
|
10
|
-
"exports":
|
|
11
|
-
|
|
10
|
+
"exports": {
|
|
11
|
+
".": {
|
|
12
|
+
"import": "./lib/index.js",
|
|
13
|
+
"types": "./lib/types/index.d.ts"
|
|
14
|
+
},
|
|
15
|
+
"./global": {
|
|
16
|
+
"types": "./global/index.d.ts"
|
|
17
|
+
}
|
|
18
|
+
},
|
|
12
19
|
"bin": {
|
|
13
20
|
"vl_build": "./lib/bin/run-build.js",
|
|
14
21
|
"vl_build-watch": "./lib/bin/run-watch.js"
|
|
@@ -30,7 +37,7 @@
|
|
|
30
37
|
"@rollup/plugin-terser": "^0.4.3",
|
|
31
38
|
"@rollup/plugin-typescript": "^11.1.4",
|
|
32
39
|
"@types/node": "^18.18.3",
|
|
33
|
-
"@vitus-labs/tools-core": "1.
|
|
40
|
+
"@vitus-labs/tools-core": "1.3.0",
|
|
34
41
|
"chalk": "^5.3.0",
|
|
35
42
|
"find-up": "^6.3.0",
|
|
36
43
|
"lodash-es": "^4.17.21",
|
|
@@ -48,8 +55,8 @@
|
|
|
48
55
|
},
|
|
49
56
|
"devDependencies": {
|
|
50
57
|
"@types/lodash-es": "^4.17.9",
|
|
51
|
-
"@vitus-labs/tools-typescript": "1.
|
|
58
|
+
"@vitus-labs/tools-typescript": "1.3.0",
|
|
52
59
|
"typescript": "^5.2.2"
|
|
53
60
|
},
|
|
54
|
-
"gitHead": "
|
|
61
|
+
"gitHead": "d875857837e45fda7b12fb939f39b2b2bb766017"
|
|
55
62
|
}
|
package/src/rollup/config.ts
CHANGED
|
@@ -24,7 +24,7 @@ const defineExtensions = (platform) => {
|
|
|
24
24
|
return platformExtensions.concat(CONFIG.extensions)
|
|
25
25
|
}
|
|
26
26
|
|
|
27
|
-
const loadPlugins = ({ env, platform,
|
|
27
|
+
const loadPlugins = ({ env, platform, file, typesFilePath }) => {
|
|
28
28
|
const extensions = defineExtensions(platform)
|
|
29
29
|
const plugins = [nodeResolve({ extensions, browser: platform === 'browser' })]
|
|
30
30
|
|
|
@@ -37,6 +37,8 @@ const loadPlugins = ({ env, platform, types, file }) => {
|
|
|
37
37
|
tsconfigDefaults: {
|
|
38
38
|
exclude: CONFIG.exclude,
|
|
39
39
|
include: CONFIG.include,
|
|
40
|
+
declarationMap: false,
|
|
41
|
+
declaration: false,
|
|
40
42
|
compilerOptions: {
|
|
41
43
|
types: ['@vitus-labs/tools-rollup'],
|
|
42
44
|
plugins: [
|
|
@@ -50,15 +52,15 @@ const loadPlugins = ({ env, platform, types, file }) => {
|
|
|
50
52
|
},
|
|
51
53
|
}
|
|
52
54
|
|
|
53
|
-
if (
|
|
54
|
-
tsConfig.tsconfigDefaults.compilerOptions.declarationMap =
|
|
55
|
-
tsConfig.tsconfigDefaults.compilerOptions.declaration =
|
|
55
|
+
if (typesFilePath) {
|
|
56
|
+
tsConfig.tsconfigDefaults.compilerOptions.declarationMap = true
|
|
57
|
+
tsConfig.tsconfigDefaults.compilerOptions.declaration = true
|
|
56
58
|
tsConfig.tsconfigDefaults.compilerOptions.declarationDir = CONFIG.typesDir
|
|
57
59
|
}
|
|
58
60
|
|
|
59
61
|
plugins.push(typescript(tsConfig))
|
|
60
62
|
|
|
61
|
-
if (
|
|
63
|
+
if (typesFilePath) {
|
|
62
64
|
plugins.push(
|
|
63
65
|
apiExtractor({
|
|
64
66
|
cleanUpRollup: true,
|
|
@@ -71,7 +73,7 @@ const loadPlugins = ({ env, platform, types, file }) => {
|
|
|
71
73
|
},
|
|
72
74
|
dtsRollup: {
|
|
73
75
|
enabled: true,
|
|
74
|
-
untrimmedFilePath: `<projectFolder>${
|
|
76
|
+
untrimmedFilePath: `<projectFolder>${typesFilePath}`,
|
|
75
77
|
},
|
|
76
78
|
},
|
|
77
79
|
}),
|
|
@@ -131,10 +133,10 @@ const rollupConfig = ({
|
|
|
131
133
|
file,
|
|
132
134
|
format,
|
|
133
135
|
env,
|
|
134
|
-
|
|
136
|
+
typesFilePath,
|
|
135
137
|
platform,
|
|
136
138
|
}: Record<string, any>) => {
|
|
137
|
-
const plugins = loadPlugins({ file, env,
|
|
139
|
+
const plugins = loadPlugins({ file, env, typesFilePath, platform })
|
|
138
140
|
|
|
139
141
|
const buildOutput = {
|
|
140
142
|
makeAbsoluteExternalsRelative: true,
|
|
@@ -1,9 +1,11 @@
|
|
|
1
|
-
import { PKG
|
|
1
|
+
import { PKG } from '../config/index.js'
|
|
2
2
|
|
|
3
|
-
const
|
|
4
|
-
const
|
|
5
|
-
|
|
6
|
-
const
|
|
3
|
+
const isESModuleOnly = PKG.type === 'module'
|
|
4
|
+
const typesFilePath = PKG?.exports?.types || PKG.types || PKG.typings
|
|
5
|
+
|
|
6
|
+
const hasDifferentNativeBuild = () => {
|
|
7
|
+
return PKG['react-native'] !== PKG.module
|
|
8
|
+
}
|
|
7
9
|
|
|
8
10
|
const hasDifferentBrowserBuild = (type) => {
|
|
9
11
|
if (!PKG.browser) return false
|
|
@@ -16,9 +18,9 @@ const hasDifferentBrowserBuild = (type) => {
|
|
|
16
18
|
})
|
|
17
19
|
}
|
|
18
20
|
|
|
19
|
-
const
|
|
21
|
+
const BUILD_VARIANTS = {
|
|
20
22
|
main: {
|
|
21
|
-
format:
|
|
23
|
+
format: isESModuleOnly ? 'es' : 'cjs',
|
|
22
24
|
env: 'development',
|
|
23
25
|
platform: 'universal',
|
|
24
26
|
},
|
|
@@ -45,7 +47,7 @@ const getExportsOptions = () => {
|
|
|
45
47
|
return [
|
|
46
48
|
{
|
|
47
49
|
file: PKG.exports,
|
|
48
|
-
...
|
|
50
|
+
...BUILD_VARIANTS.module,
|
|
49
51
|
},
|
|
50
52
|
]
|
|
51
53
|
}
|
|
@@ -56,21 +58,21 @@ const getExportsOptions = () => {
|
|
|
56
58
|
if (exportsOptions.import) {
|
|
57
59
|
result.push({
|
|
58
60
|
file: exportsOptions.import,
|
|
59
|
-
...
|
|
61
|
+
...BUILD_VARIANTS.module,
|
|
60
62
|
})
|
|
61
63
|
}
|
|
62
64
|
|
|
63
65
|
if (exportsOptions.require) {
|
|
64
66
|
result.push({
|
|
65
67
|
file: exportsOptions.require,
|
|
66
|
-
...
|
|
68
|
+
...BUILD_VARIANTS.main,
|
|
67
69
|
})
|
|
68
70
|
}
|
|
69
71
|
|
|
70
72
|
if (exportsOptions.node) {
|
|
71
73
|
result.push({
|
|
72
74
|
file: exportsOptions.node,
|
|
73
|
-
...
|
|
75
|
+
...BUILD_VARIANTS.module,
|
|
74
76
|
platform: 'node',
|
|
75
77
|
})
|
|
76
78
|
}
|
|
@@ -78,7 +80,7 @@ const getExportsOptions = () => {
|
|
|
78
80
|
if (exportsOptions.default) {
|
|
79
81
|
result.push({
|
|
80
82
|
file: exportsOptions.default,
|
|
81
|
-
...
|
|
83
|
+
...BUILD_VARIANTS.module,
|
|
82
84
|
})
|
|
83
85
|
}
|
|
84
86
|
|
|
@@ -91,22 +93,23 @@ const getExportsOptions = () => {
|
|
|
91
93
|
const createBasicBuildVariants = () => {
|
|
92
94
|
let result: Record<string, any>[] = []
|
|
93
95
|
|
|
94
|
-
if (
|
|
96
|
+
if (isESModuleOnly) result = [...getExportsOptions()]
|
|
95
97
|
|
|
96
|
-
Object.keys(
|
|
98
|
+
Object.keys(BUILD_VARIANTS).forEach((key) => {
|
|
97
99
|
const PKGOutDir = PKG[key]
|
|
98
100
|
|
|
99
101
|
if (PKGOutDir) {
|
|
100
102
|
const hasBrowserBuild = hasDifferentBrowserBuild(key)
|
|
103
|
+
const hasNativeBuild = hasDifferentNativeBuild()
|
|
101
104
|
|
|
102
105
|
// create a helper function for adding a build variant to an array
|
|
103
106
|
const add = (props = {}) => {
|
|
104
|
-
result.push({ ...
|
|
107
|
+
result.push({ ...BUILD_VARIANTS[key], file: PKGOutDir, ...props })
|
|
105
108
|
}
|
|
106
109
|
|
|
107
110
|
if (key === 'react-native') {
|
|
108
111
|
// add a separate RN build only if output path differs from module path
|
|
109
|
-
if (
|
|
112
|
+
if (hasNativeBuild) {
|
|
110
113
|
add()
|
|
111
114
|
}
|
|
112
115
|
} else if (hasBrowserBuild) {
|
|
@@ -130,10 +133,10 @@ const createBrowserBuildVariants = () => {
|
|
|
130
133
|
const source = key.substring(2) // strip './' from the beginning of path
|
|
131
134
|
const output = value.substring(2) // strip './' from the beginning of path
|
|
132
135
|
|
|
133
|
-
Object.keys(
|
|
136
|
+
Object.keys(BUILD_VARIANTS).forEach((item) => {
|
|
134
137
|
if (PKG[item] === source && source !== output) {
|
|
135
138
|
result.push({
|
|
136
|
-
...
|
|
139
|
+
...BUILD_VARIANTS[item],
|
|
137
140
|
file: output,
|
|
138
141
|
platform: 'browser',
|
|
139
142
|
})
|
|
@@ -151,7 +154,9 @@ const createBuildPipeline = () => {
|
|
|
151
154
|
]
|
|
152
155
|
|
|
153
156
|
// add generate typings for the first bundle only
|
|
154
|
-
|
|
157
|
+
if (!!typesFilePath) {
|
|
158
|
+
result[0] = { ...result[0], typesFilePath }
|
|
159
|
+
}
|
|
155
160
|
|
|
156
161
|
return result
|
|
157
162
|
}
|