Skip to content

Commit

Permalink
chore: add postinstall for git-hooks
Browse files Browse the repository at this point in the history
  • Loading branch information
花果山大圣 committed Jun 9, 2023
1 parent 4f22b03 commit f0a3529
Show file tree
Hide file tree
Showing 41 changed files with 779 additions and 707 deletions.
3 changes: 2 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
"private": true,
"scripts": {
"preinstall": "npx only-allow pnpm",
"postinstall": "simple-git-hooks",
"test": "turbo run test test-types",
"coverage": "turbo run coverage",
"build": "turbo run build",
Expand Down Expand Up @@ -57,7 +58,7 @@
"vitest": "^0.29.3"
},
"simple-git-hooks": {
"pre-commit": "pnpm exec format"
"pre-commit": "pnpm run format"
},
"pnpm": {
"overrides": {
Expand Down
68 changes: 34 additions & 34 deletions packages/babel-preset-solid/index.js
Original file line number Diff line number Diff line change
@@ -1,34 +1,34 @@
const jsxTransform = require("babel-plugin-jsx-dom-expressions");

module.exports = function (context, options = {}) {
const plugins = [
[
jsxTransform,
Object.assign(
{
moduleName: "solid-js/web",
builtIns: [
"For",
"Show",
"Switch",
"Match",
"Suspense",
"SuspenseList",
"Portal",
"Index",
"Dynamic",
"ErrorBoundary"
],
contextToCustomElements: true,
wrapConditionals: true,
generate: "dom"
},
options
)
]
];

return {
plugins
};
};
const jsxTransform = require("babel-plugin-jsx-dom-expressions");

module.exports = function (context, options = {}) {
const plugins = [
[
jsxTransform,
Object.assign(
{
moduleName: "solid-js/web",
builtIns: [
"For",
"Show",
"Switch",
"Match",
"Suspense",
"SuspenseList",
"Portal",
"Index",
"Dynamic",
"ErrorBoundary"
],
contextToCustomElements: true,
wrapConditionals: true,
generate: "dom"
},
options
)
]
];

return {
plugins
};
};
30 changes: 15 additions & 15 deletions packages/babel-preset-solid/test.js
Original file line number Diff line number Diff line change
@@ -1,15 +1,15 @@
const babel = require("@babel/core");
const preset = require(".");
const assert = require("assert");

const { code } = babel.transformSync("const v = <div a b={2} />;", {
presets: [preset],
babelrc: false,
compact: true
});

assert.equal(
code,
'import{template as _$template}from"solid-js/web";const _tmpl$=/*#__PURE__*/_$template(`<div a b="2">`);const v=_tmpl$();'
);
console.log("passed");
const babel = require("@babel/core");
const preset = require(".");
const assert = require("assert");

const { code } = babel.transformSync("const v = <div a b={2} />;", {
presets: [preset],
babelrc: false,
compact: true
});

assert.equal(
code,
'import{template as _$template}from"solid-js/web";const _tmpl$=/*#__PURE__*/_$template(`<div a b="2">`);const v=_tmpl$();'
);
console.log("passed");
46 changes: 23 additions & 23 deletions packages/solid-ssr/examples/async/index.js
Original file line number Diff line number Diff line change
@@ -1,23 +1,23 @@
import express from "express";
import url from "url";

import { renderToStringAsync } from "solid-js/web";
import App from "../shared/src/components/App";

const app = express();
const port = 8080;

app.use(express.static(url.fileURLToPath(new URL("../public", import.meta.url))));

app.get("*", async (req, res) => {
let result;
try {
result = await renderToStringAsync(() => <App url={req.url} />);
} catch (err) {
console.error(err);
} finally {
res.send(result);
}
});

app.listen(port, () => console.log(`Example app listening on port ${port}!`));
import express from "express";
import url from "url";

import { renderToStringAsync } from "solid-js/web";
import App from "../shared/src/components/App";

const app = express();
const port = 8080;

app.use(express.static(url.fileURLToPath(new URL("../public", import.meta.url))));

app.get("*", async (req, res) => {
let result;
try {
result = await renderToStringAsync(() => <App url={req.url} />);
} catch (err) {
console.error(err);
} finally {
res.send(result);
}
});

app.listen(port, () => console.log(`Example app listening on port ${port}!`));
104 changes: 52 additions & 52 deletions packages/solid-ssr/examples/async/rollup.config.js
Original file line number Diff line number Diff line change
@@ -1,52 +1,52 @@
import nodeResolve from "@rollup/plugin-node-resolve";
import common from "@rollup/plugin-commonjs";
import babel from "@rollup/plugin-babel";
import copy from "rollup-plugin-copy";

export default [
{
input: "examples/async/index.js",
output: [
{
dir: "examples/async/lib",
format: "esm"
}
],
preserveEntrySignatures: false,
external: ["solid-js", "solid-js/web", "path", "express"],
plugins: [
nodeResolve({ preferBuiltins: true, exportConditions: ["solid", "node"] }),
babel({
babelHelpers: "bundled",
presets: [["solid", { generate: "ssr", hydratable: true }]]
}),
common()
]
},
{
input: "examples/shared/src/index.js",
output: [
{
dir: "examples/async/public/js",
format: "esm"
}
],
preserveEntrySignatures: false,
plugins: [
nodeResolve({ exportConditions: ["solid"] }),
babel({
babelHelpers: "bundled",
presets: [["solid", { generate: "dom", hydratable: true }]]
}),
common(),
copy({
targets: [
{
src: ["examples/shared/static/*"],
dest: "examples/async/public"
}
]
})
]
}
];
import nodeResolve from "@rollup/plugin-node-resolve";
import common from "@rollup/plugin-commonjs";
import babel from "@rollup/plugin-babel";
import copy from "rollup-plugin-copy";

export default [
{
input: "examples/async/index.js",
output: [
{
dir: "examples/async/lib",
format: "esm"
}
],
preserveEntrySignatures: false,
external: ["solid-js", "solid-js/web", "path", "express"],
plugins: [
nodeResolve({ preferBuiltins: true, exportConditions: ["solid", "node"] }),
babel({
babelHelpers: "bundled",
presets: [["solid", { generate: "ssr", hydratable: true }]]
}),
common()
]
},
{
input: "examples/shared/src/index.js",
output: [
{
dir: "examples/async/public/js",
format: "esm"
}
],
preserveEntrySignatures: false,
plugins: [
nodeResolve({ exportConditions: ["solid"] }),
babel({
babelHelpers: "bundled",
presets: [["solid", { generate: "dom", hydratable: true }]]
}),
common(),
copy({
targets: [
{
src: ["examples/shared/static/*"],
dest: "examples/async/public"
}
]
})
]
}
];

0 comments on commit f0a3529

Please sign in to comment.