@linktr.ee/create-link-app 0.3.0-next.33 → 0.3.0-next.34
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.
|
@@ -43,10 +43,33 @@ function toVirtualModule(code) {
|
|
|
43
43
|
const base64 = Buffer.from(code).toString('base64');
|
|
44
44
|
return `data:text/javascript;base64,${base64}`;
|
|
45
45
|
}
|
|
46
|
+
function hasEntrypoint(appDir, file) {
|
|
47
|
+
try {
|
|
48
|
+
fs_1.default.accessSync(path_1.default.resolve(appDir, 'src', file));
|
|
49
|
+
return true;
|
|
50
|
+
}
|
|
51
|
+
catch {
|
|
52
|
+
return false;
|
|
53
|
+
}
|
|
54
|
+
}
|
|
46
55
|
async function default_1(env, options) {
|
|
47
56
|
const appDir = process.cwd();
|
|
48
57
|
const entryFile = path_1.default.resolve(__dirname, `${env}.entry`);
|
|
49
58
|
const htmlTemplateFile = path_1.default.resolve(__dirname, '..', '..', 'html-template', `${env}.html`);
|
|
59
|
+
const useAppEntry = hasEntrypoint(appDir, 'App.tsx');
|
|
60
|
+
const useSheetEntry = hasEntrypoint(appDir, 'Sheet.tsx');
|
|
61
|
+
const useEditorEntry = hasEntrypoint(appDir, 'Editor.tsx');
|
|
62
|
+
const exposedEntryPoints = {
|
|
63
|
+
// Default entry points
|
|
64
|
+
['./App']: useAppEntry ? path_1.default.resolve(appDir, 'src/App') : path_1.default.resolve(appDir, 'src'),
|
|
65
|
+
['./validate']: toVirtualModule((await (0, compile_1.default)())),
|
|
66
|
+
};
|
|
67
|
+
if (useEditorEntry) {
|
|
68
|
+
exposedEntryPoints['./Editor'] = path_1.default.resolve(appDir, 'src/Editor');
|
|
69
|
+
}
|
|
70
|
+
if (useSheetEntry) {
|
|
71
|
+
exposedEntryPoints['./Sheet'] = path_1.default.resolve(appDir, 'src/Sheet');
|
|
72
|
+
}
|
|
50
73
|
const manifestJson = JSON.parse(fs_1.default.readFileSync(path_1.default.resolve(appDir, 'manifest.json'), 'utf8'));
|
|
51
74
|
const linkTypeName = manifestJson.name.replace(/[^A-Za-z0-9 ]/g, '');
|
|
52
75
|
const linkTypeSlug = (0, slugify_1.default)(linkTypeName, { lower: true });
|
|
@@ -103,7 +126,7 @@ async function default_1(env, options) {
|
|
|
103
126
|
// TODO: The behaviour here with module resolution is confusing, can we make it more explicit?
|
|
104
127
|
modules: [path_1.default.resolve(appDir, 'node_modules'), 'node_modules'],
|
|
105
128
|
alias: {
|
|
106
|
-
'@linktr.ee/extension':
|
|
129
|
+
'@linktr.ee/extension': exposedEntryPoints['./App'],
|
|
107
130
|
},
|
|
108
131
|
},
|
|
109
132
|
plugins: [
|
|
@@ -149,12 +172,7 @@ async function default_1(env, options) {
|
|
|
149
172
|
}), new ModuleFederationPlugin({
|
|
150
173
|
name: `LinkApp_${linkTypeId}`,
|
|
151
174
|
filename: 'remoteEntry.js',
|
|
152
|
-
exposes:
|
|
153
|
-
['./App']: path_1.default.resolve(appDir, 'src/App'),
|
|
154
|
-
['./Sheet']: path_1.default.resolve(appDir, 'src/Sheet'),
|
|
155
|
-
['./Editor']: path_1.default.resolve(appDir, 'src/Editor'),
|
|
156
|
-
['./validate']: toVirtualModule((await (0, compile_1.default)())),
|
|
157
|
-
},
|
|
175
|
+
exposes: exposedEntryPoints,
|
|
158
176
|
shared: {
|
|
159
177
|
react: {
|
|
160
178
|
singleton: true,
|
package/oclif.manifest.json
CHANGED