This repository has been archived by the owner on Aug 1, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
chore: add example of lodash via jsdelivr
- Loading branch information
1 parent
4306035
commit c7aa4f8
Showing
7 changed files
with
124 additions
and
17 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
/bundle.js |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
import { esbuild } from '../../deps.ts'; | ||
import esbuildCachePlugin from '../../mod.ts'; | ||
|
||
const importMap = JSON.parse(Deno.readTextFileSync('./import_map.json')); | ||
const lockMap = JSON.parse(Deno.readTextFileSync('./deno.lock')); | ||
|
||
const denoPath = await esbuildCachePlugin.util.getDenoDir(); | ||
await esbuild.build({ | ||
entryPoints: ['./index.ts'], | ||
bundle: true, | ||
outfile: './bundle.js', | ||
plugins: [ | ||
esbuildCachePlugin({ | ||
denoCacheDirectory: denoPath, | ||
lockMap, | ||
importMap, | ||
}), | ||
], | ||
}); | ||
|
||
await esbuild.stop(); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
{ | ||
"importMap": "import_map.json", | ||
"tasks": { | ||
"build": "deno run -A build.ts", | ||
"cache": "rm deno.lock && deno cache **/*.ts" | ||
} | ||
} |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
{ | ||
"imports": { | ||
"lodash": "https://cdn.jsdelivr.net/npm/lodash/+esm" | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
import _ from 'lodash'; | ||
|
||
console.log(_.merge( | ||
{ a: { b: 0 } }, | ||
{ a: { c: 1 }, d: 2 }, | ||
)); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,18 +1,3 @@ | ||
# Example: Import Map | ||
# Example: Lodash from jsDelivr | ||
|
||
You can use import maps to map imports with `importMap` option: | ||
|
||
```javascript | ||
esbuildCachePlugin({ | ||
importMap: { | ||
"imports": { | ||
"https://example.com/foo/": "./src/polyfill/foo/" | ||
}, | ||
"scopes": { | ||
"./src/foo.ts": { | ||
"https://example.com/foo/": "./src/polyfill/bar/" | ||
} | ||
} | ||
}, | ||
}), | ||
``` | ||
Using Lodash from jsDelivr, mapping `lodash` to remote URL (see `import_map.json`.) |