@ossy/app 1.16.1 → 1.16.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/cli/build.task.js +15 -10
- package/cli/manifest-plugin.js +11 -0
- package/package.json +11 -11
package/cli/build.task.js
CHANGED
|
@@ -46,11 +46,21 @@ function ensureDir (dir) {
|
|
|
46
46
|
fs.mkdirSync(dir, { recursive: true })
|
|
47
47
|
}
|
|
48
48
|
|
|
49
|
-
|
|
49
|
+
// One source of truth for the per-entry name. Used both as the Rollup
|
|
50
|
+
// `input` key (which becomes the `[name]` token in `entryFileNames`) and
|
|
51
|
+
// as the basename of the generated stub. Flattening the full relative
|
|
52
|
+
// path with `__` keeps two files with the same basename in different
|
|
53
|
+
// folders (e.g. `apps/home.page.jsx` and `analytics/home.page.jsx`) from
|
|
54
|
+
// colliding on the Rollup input map — which the filesystem already
|
|
55
|
+
// guarantees can't happen at the relative-path level.
|
|
56
|
+
function entryNameFromSource (sourcePath, srcDir) {
|
|
50
57
|
const rel = path.relative(srcDir, sourcePath).replace(/\\/g, '/')
|
|
51
|
-
|
|
58
|
+
return rel.replace(/\//g, '__').replace(/\.(jsx?|tsx?|mjs|cjs)$/, '')
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
function stubFileNameFor (kind, sourcePath, srcDir) {
|
|
52
62
|
const ext = kind === 'page' ? '.entry.jsx' : '.entry.js'
|
|
53
|
-
return
|
|
63
|
+
return entryNameFromSource(sourcePath, srcDir) + ext
|
|
54
64
|
}
|
|
55
65
|
|
|
56
66
|
function relImport (fromAbs, toAbs) {
|
|
@@ -148,14 +158,9 @@ export async function build (cliArgs = []) {
|
|
|
148
158
|
|
|
149
159
|
for (const entry of allEntries) {
|
|
150
160
|
const { kind, sourcePath } = entry
|
|
151
|
-
const
|
|
152
|
-
const stubAbs = path.join(stubDir,
|
|
161
|
+
const inputName = entryNameFromSource(sourcePath, srcDir)
|
|
162
|
+
const stubAbs = path.join(stubDir, stubFileNameFor(kind, sourcePath, srcDir))
|
|
153
163
|
fs.writeFileSync(stubAbs, stubFor(kind, { stubAbs, sourceAbs: sourcePath }), 'utf8')
|
|
154
|
-
|
|
155
|
-
const inputName = path.basename(sourcePath).replace(/\.(jsx?|tsx?|mjs|cjs)$/, '')
|
|
156
|
-
if (stubInputMap[inputName]) {
|
|
157
|
-
throw new Error(`[@ossy/app][build] Duplicate entry name "${inputName}" between ${stubInputMap[inputName]} and ${stubAbs}.`)
|
|
158
|
-
}
|
|
159
164
|
stubInputMap[inputName] = stubAbs
|
|
160
165
|
entriesByStub.set(stubAbs, { kind, sourcePath })
|
|
161
166
|
}
|
package/cli/manifest-plugin.js
CHANGED
|
@@ -123,6 +123,17 @@ export function manifestPlugin ({ entriesByStub, srcDir, staticOutDir, configVal
|
|
|
123
123
|
const pagePath = rawMeta.path !== undefined ? rawMeta.path : defaultPageRoute(id)
|
|
124
124
|
entries.push({ type: 'page', id, path: pagePath, title: rawMeta.title, entry: url })
|
|
125
125
|
} else if (entryInfo.kind === 'api') {
|
|
126
|
+
// APIs have no sensible default route (unlike pages where we can
|
|
127
|
+
// derive `/<id>`). Failing here surfaces a missing `metadata.path`
|
|
128
|
+
// at build time instead of letting it 500 the router on first
|
|
129
|
+
// request — `OssyRouter.getPageByUrl` does `Object.entries(path)`
|
|
130
|
+
// and crashes when `path` is undefined.
|
|
131
|
+
if (rawMeta.path === undefined || rawMeta.path === null) {
|
|
132
|
+
this.error(
|
|
133
|
+
`[@ossy/app][build] api entry "${id}" (${entryInfo.sourcePath}) is missing metadata.path. ` +
|
|
134
|
+
`Add a \`path\` to the metadata or default-export object (e.g. \`path: '/api/${id}'\`).`,
|
|
135
|
+
)
|
|
136
|
+
}
|
|
126
137
|
entries.push({ type: 'api', id, path: rawMeta.path, entry: url })
|
|
127
138
|
} else {
|
|
128
139
|
entries.push({ type: 'task', id, entry: url })
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@ossy/app",
|
|
3
|
-
"version": "1.16.
|
|
3
|
+
"version": "1.16.3",
|
|
4
4
|
"description": "",
|
|
5
5
|
"source": "./src/index.js",
|
|
6
6
|
"main": "./src/index.js",
|
|
@@ -33,15 +33,15 @@
|
|
|
33
33
|
"@babel/eslint-parser": "^7.15.8",
|
|
34
34
|
"@babel/preset-react": "^7.26.3",
|
|
35
35
|
"@babel/register": "^7.25.9",
|
|
36
|
-
"@ossy/connected-components": "^1.16.
|
|
37
|
-
"@ossy/design-system": "^1.16.
|
|
38
|
-
"@ossy/pages": "^1.16.
|
|
39
|
-
"@ossy/platform": "^1.15.
|
|
40
|
-
"@ossy/router": "^1.16.
|
|
41
|
-
"@ossy/router-react": "^1.16.
|
|
42
|
-
"@ossy/sdk": "^1.16.
|
|
43
|
-
"@ossy/sdk-react": "^1.16.
|
|
44
|
-
"@ossy/themes": "^1.16.
|
|
36
|
+
"@ossy/connected-components": "^1.16.3",
|
|
37
|
+
"@ossy/design-system": "^1.16.3",
|
|
38
|
+
"@ossy/pages": "^1.16.3",
|
|
39
|
+
"@ossy/platform": "^1.15.3",
|
|
40
|
+
"@ossy/router": "^1.16.3",
|
|
41
|
+
"@ossy/router-react": "^1.16.3",
|
|
42
|
+
"@ossy/sdk": "^1.16.3",
|
|
43
|
+
"@ossy/sdk-react": "^1.16.3",
|
|
44
|
+
"@ossy/themes": "^1.16.3",
|
|
45
45
|
"@rollup/plugin-alias": "^6.0.0",
|
|
46
46
|
"@rollup/plugin-babel": "6.1.0",
|
|
47
47
|
"@rollup/plugin-commonjs": "^29.0.0",
|
|
@@ -75,5 +75,5 @@
|
|
|
75
75
|
"README.md",
|
|
76
76
|
"tsconfig.json"
|
|
77
77
|
],
|
|
78
|
-
"gitHead": "
|
|
78
|
+
"gitHead": "57ef30cf0b510dfb09b5b964cff3d847b9825360"
|
|
79
79
|
}
|