Skip to content

Commit aad2680

Browse files
Revert "feat(npm-scripts): add support for multiple entry points"
This reverts commit a2054e8.
1 parent 4618a0a commit aad2680

File tree

3 files changed

+27
-48
lines changed

3 files changed

+27
-48
lines changed

projects/npm-tools/packages/npm-scripts/src/utils/createEsm2AmdIndexBridge.js

Lines changed: 22 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ const getBndWebContextPath = require('./getBndWebContextPath');
1919
function createEsm2AmdIndexBridge(projectDir, buildConfig, manifest) {
2020
const pkgJson = require(path.join(projectDir, 'package.json'));
2121

22-
const {main, output} = buildConfig;
22+
const {output} = buildConfig;
2323

2424
const webContextPath = getBndWebContextPath(projectDir);
2525

@@ -34,42 +34,32 @@ function createEsm2AmdIndexBridge(projectDir, buildConfig, manifest) {
3434
// level appears under `/o/js/resolved-module/...`.
3535
//
3636

37-
for (const fileName of main) {
38-
const baseName = path.parse(fileName).name;
37+
const rootDir = pkgJson.name.startsWith('@') ? '../../../..' : '../../..';
3938

40-
const rootDir = pkgJson.name.startsWith('@')
41-
? '../../../..'
42-
: '../../..';
39+
const bridgeSource = `
40+
import * as esModule from "${rootDir}${webContextPath}/__liferay__/index.js";
4341
44-
const bridgeSource = `
45-
import * as esModule from "${rootDir}${webContextPath}/__liferay__/${baseName}.js";
46-
47-
Liferay.Loader.define(
48-
"${pkgJson.name}@${pkgJson.version}/${baseName}",
49-
['module'],
50-
function (module) {
51-
module.exports = esModule;
52-
}
53-
);
54-
`;
42+
Liferay.Loader.define(
43+
"${pkgJson.name}@${pkgJson.version}/index",
44+
['module'],
45+
function (module) {
46+
module.exports = esModule;
47+
}
48+
);
49+
`;
5550

56-
fs.writeFileSync(
57-
path.resolve(output, baseName + '.js'),
58-
bridgeSource,
59-
'utf8'
60-
);
51+
fs.writeFileSync(path.resolve(output, 'index.js'), bridgeSource, 'utf8');
6152

62-
manifest.packages = manifest.packages ?? {};
63-
manifest.packages['/'] = manifest.packages['/'] ?? {};
64-
manifest.packages['/'].modules = manifest.packages['/'].modules ?? {};
53+
manifest.packages = manifest.packages ?? {};
54+
manifest.packages['/'] = manifest.packages['/'] ?? {};
55+
manifest.packages['/'].modules = manifest.packages['/'].modules ?? {};
6556

66-
manifest.packages['/'].modules['index.js'] = {
67-
flags: {
68-
esModule: true,
69-
useESM: true,
70-
},
71-
};
72-
}
57+
manifest.packages['/'].modules['index.js'] = {
58+
flags: {
59+
esModule: true,
60+
useESM: true,
61+
},
62+
};
7363
}
7464

7565
module.exports = createEsm2AmdIndexBridge;

projects/npm-tools/packages/npm-scripts/src/utils/getMergedConfig.js

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -241,10 +241,6 @@ function normalizeNpmscriptsConfig(mergedConfig) {
241241
if (mergedConfig.build.exports === undefined) {
242242
mergedConfig.build.exports = [];
243243
}
244-
245-
if (!Array.isArray(mergedConfig.build.main)) {
246-
mergedConfig.build.main = [mergedConfig.build.main];
247-
}
248244
}
249245

250246
if (Array.isArray(mergedConfig.build?.exports)) {

projects/npm-tools/packages/npm-scripts/src/utils/runWebpackAsBundler.js

Lines changed: 5 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -65,24 +65,17 @@ function getIndexWebpackConfig(projectDir, buildConfig, babelConfig) {
6565
return;
6666
}
6767

68-
const mainFilePaths = buildConfig.main.map((main) =>
69-
path.resolve(projectDir, main)
70-
);
68+
const mainFilePath = path.resolve(projectDir, buildConfig.main);
7169

7270
const {imports} = buildConfig;
7371
const externals = convertImportsToExternals(imports, 2);
7472

75-
const entry = mainFilePaths.reduce((acc, mainFilePath) => {
76-
return {
77-
...acc,
78-
[`__liferay__/${path.parse(mainFilePath).name}`]: {
73+
const webpackConfig = {
74+
entry: {
75+
[`__liferay__/index`]: {
7976
import: mainFilePath,
8077
},
81-
};
82-
}, {});
83-
84-
const webpackConfig = {
85-
entry,
78+
},
8679
experiments: {
8780
outputModule: true,
8881
},

0 commit comments

Comments
 (0)