-
Notifications
You must be signed in to change notification settings - Fork 130
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Make the SDK friendly to locally link and develop on #693
Changes from 1 commit
cd007b4
8fb2b27
0023ab3
d247bc4
95d1730
dd06d78
2401b7f
12d6447
f61bf60
f56dc58
e9cee2e
f1e07b6
ce289ba
d053d43
75098b4
e54482e
639358b
b725269
1b2a6b5
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -2,6 +2,17 @@ | |
"name": "hydrogen-view-sdk", | ||
"description": "Embeddable matrix client library, including view components", | ||
"version": "0.0.5", | ||
"main": "./hydrogen.es.js", | ||
"main": "./hydrogen.cjs.js", | ||
"exports": { | ||
".": { | ||
"import": "./lib-build/hydrogen.es.js", | ||
"require": "./lib-build/hydrogen.cjs.js" | ||
}, | ||
"./paths/vite": "./paths/vite.js", | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This export isn't used but it's part of the |
||
"./style.css": "./asset-build/assets/index.css", | ||
"./main.js": "./asset-build/assets/download-sandbox.html", | ||
"./download-sandbox.html": "./asset-build/assets/download-sandbox.html", | ||
"./assets/*": "./asset-build/assets/*" | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Fix #682 Make the assets path available to reference and serve separately. app.use(express.static(path.dirname(require.resolve('hydrogen-view-sdk/assets/main.js')))); |
||
}, | ||
"type": "module" | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,5 @@ | ||
#!/bin/bash | ||
rm -rf target | ||
rm -rf target/* | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Only remove the directory contents instead of the whole directory to maintain the There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Added as a comment to the script |
||
yarn run vite build -c vite.sdk-assets-config.js | ||
yarn run vite build -c vite.sdk-lib-config.js | ||
yarn tsc -p tsconfig-declaration.json | ||
|
@@ -10,13 +10,7 @@ mkdir target/paths | |
cp doc/SDK.md target/README.md | ||
pushd target | ||
pushd asset-build/assets | ||
mv main.*.js ../../main.js | ||
mv index.*.css ../../style.css | ||
mv download-sandbox.*.html ../../download-sandbox.html | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Instead of needing to move these 3 files and rename them without the hash here, we handle removing the hash in |
||
rm *.js *.wasm | ||
mv ./* ../../ | ||
rm !(main).js *.wasm | ||
MadLittleMods marked this conversation as resolved.
Show resolved
Hide resolved
MadLittleMods marked this conversation as resolved.
Show resolved
Hide resolved
|
||
popd | ||
rm -rf asset-build | ||
mv lib-build/* . | ||
rm -rf lib-build | ||
rm index.html | ||
popd |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -2,10 +2,29 @@ const path = require("path"); | |
const mergeOptions = require('merge-options'); | ||
const commonOptions = require("./vite.common-config.js"); | ||
|
||
const pathsToExport = [ | ||
"index.js", | ||
"index.css", | ||
"download-sandbox.html" | ||
]; | ||
|
||
export default mergeOptions(commonOptions, { | ||
root: "src/", | ||
base: "./", | ||
build: { | ||
outDir: "../target/asset-build/", | ||
rollupOptions: { | ||
output: { | ||
assetFileNames: (chunkInfo) => { | ||
// Get rid of the hash so we can consistently reference these | ||
// files in our `package.json` `exports` | ||
if(pathsToExport.includes(path.basename(chunkInfo.name))) { | ||
return "assets/[name].[ext]"; | ||
} | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Instead of renaming these files in |
||
|
||
return "assets/[name]-[hash][extname]"; | ||
} | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. For reference, docs for the |
||
} | ||
} | ||
}, | ||
}); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Referencing
hydrogen.es.js
directly in the build,./lib-build/hydrogen.es.js
, to make it compatible with watching for an local changes and rebuild:yarn run vite build -c vite.sdk-lib-config.js --watch