@linktr.ee/create-link-app 0.3.0-next.32 → 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': path_1.default.resolve(appDir, 'src'),
129
+ '@linktr.ee/extension': exposedEntryPoints['./App'],
107
130
  },
108
131
  },
109
132
  plugins: [
@@ -149,10 +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'),
154
- ['./validate']: toVirtualModule((await (0, compile_1.default)())),
155
- },
175
+ exposes: exposedEntryPoints,
156
176
  shared: {
157
177
  react: {
158
178
  singleton: true,
@@ -1,5 +1,5 @@
1
1
  {
2
- "version": "0.3.0-next.32",
2
+ "version": "0.3.0-next.34",
3
3
  "commands": {
4
4
  "build": {
5
5
  "id": "build",
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@linktr.ee/create-link-app",
3
- "version": "0.3.0-next.32",
3
+ "version": "0.3.0-next.34",
4
4
  "description": "Create a Link App on Linktr.ee.",
5
5
  "license": "UNLICENSED",
6
6
  "author": "Linktree",
@@ -1,4 +1,4 @@
1
- import { Featured, Carousel, Grid, Stack, SheetBody } from './components/Layouts'
1
+ import { Featured, Carousel, Grid, Stack } from './components/Layouts'
2
2
  import { AppProps, Layout } from './types'
3
3
 
4
4
  import './tailwind.css'
@@ -15,8 +15,6 @@ function App(props: AppProps) {
15
15
  return <Carousel {...props} />
16
16
  case Layout.Featured:
17
17
  return <Featured {...props} />
18
- case Layout.SheetBody:
19
- return <SheetBody />
20
18
  default:
21
19
  return <div>Unknown layout: {props.layout}</div>
22
20
  }
@@ -0,0 +1,7 @@
1
+ import './tailwind.css'
2
+
3
+ const Editor = () => {
4
+ return <div>Editor</div>
5
+ }
6
+
7
+ export default Editor
@@ -0,0 +1,7 @@
1
+ import './tailwind.css'
2
+
3
+ const Sheet = () => {
4
+ return <div>Sheet</div>
5
+ }
6
+
7
+ export default Sheet
@@ -50,8 +50,4 @@ const Stack = (props: AppProps) => {
50
50
  )
51
51
  }
52
52
 
53
- const SheetBody = () => {
54
- return <div>sheet body</div>
55
- }
56
-
57
- export { Featured, Carousel, Grid, Stack, SheetBody }
53
+ export { Featured, Carousel, Grid, Stack }
@@ -88,12 +88,3 @@ export const Featured: ComponentStory<typeof LinkApp> = (args) => (
88
88
  Featured.args = {
89
89
  layout: Layout.Featured,
90
90
  }
91
-
92
- export const SheetBody: ComponentStory<typeof LinkApp> = (args) => (
93
- <div className="m-2">
94
- <LinkApp {...args} />
95
- </div>
96
- )
97
- SheetBody.args = {
98
- layout: Layout.SheetBody,
99
- }