Skip to content

Commit

Permalink
Add browser export without file-system
Browse files Browse the repository at this point in the history
  • Loading branch information
pomber committed Feb 24, 2023
1 parent eabaefe commit 4111eb7
Show file tree
Hide file tree
Showing 6 changed files with 2,689 additions and 21 deletions.
5 changes: 5 additions & 0 deletions .changeset/quiet-crabs-try.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"@code-hike/lighter": minor
---

Add browser export without file-system
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -105,3 +105,5 @@ dist/*

# TernJS port file
.tern-port

todo.md
2,658 changes: 2,658 additions & 0 deletions lib/dist/browser.esm.mjs

Large diffs are not rendered by default.

1 change: 1 addition & 0 deletions lib/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
"license": "MIT",
"main": "./dist/index.cjs.js",
"module": "./dist/index.esm.mjs",
"browser": "./dist/browser.esm.mjs",
"types": "./dist/index.d.ts",
"files": [
"dist/",
Expand Down
41 changes: 20 additions & 21 deletions lib/rollup.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,33 +8,32 @@ import dts from "rollup-plugin-dts";

const pkg = require("./package.json");

const plugins = [
replace({ __LIGHTER_VERSION__: `${pkg.version}`, preventAssignment: false }),
json(),
nodeResolve(),
typescript({
tsconfigDefaults: { compilerOptions: { module: "esnext" } },
}),
arraybuffer({ include: "**/*.wasm" }),
commonjs(),
];

export default [
{
input: "src/index.ts",
output: [
{
file: "dist/index.cjs.js",
format: "cjs",
},
{
file: "dist/index.esm.mjs",
format: "esm",
},
{ file: "dist/index.cjs.js", format: "cjs" },
{ file: "dist/index.esm.mjs", format: "esm" },
],
plugins,
},
{
input: "src/index.ts",
output: [{ file: "dist/browser.esm.mjs", format: "esm" }],
plugins: [
replace({
__LIGHTER_VERSION__: `${pkg.version}`,
preventAssignment: false,
}),
json(),
nodeResolve(),
typescript({
tsconfigDefaults: {
compilerOptions: { module: "esnext" },
},
}),
arraybuffer({ include: "**/*.wasm" }),
commonjs(),
replace({ "file-system": "file-system.fake", preventAssignment: false }),
...plugins,
],
},
{
Expand Down
3 changes: 3 additions & 0 deletions lib/src/file-system.fake.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
export async function readJSON(folder: string, filename: string): Promise<any> {
throw new Error("no fs");
}

1 comment on commit 4111eb7

@vercel
Copy link

@vercel vercel bot commented on 4111eb7 Feb 24, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Successfully deployed to the following URLs:

lighter – ./

lighter-git-main-codehike.vercel.app
lighter-codehike.vercel.app
lighter.codehike.org

Please sign in to comment.