File tree Expand file tree Collapse file tree 1 file changed +12
-2
lines changed Expand file tree Collapse file tree 1 file changed +12
-2
lines changed Original file line number Diff line number Diff line change @@ -9,6 +9,7 @@ published: 2024-08-09
9
9
tags :
10
10
- browser
11
11
- dom
12
+ - esbuild
12
13
- hast
13
14
- mdast
14
15
- nlcst
@@ -78,7 +79,9 @@ And you want to use that in some HTML called `index.html`:
78
79
79
80
To make ` example.js ` work in the browser,
80
81
you can bundle it with esbuild.
81
- First, set up a package:
82
+ First,
83
+ set up a package.
84
+ Go to the folder in your terminal and run:
82
85
83
86
``` sh
84
87
npm init --yes
@@ -95,7 +98,12 @@ Now, open `index.html` in a browser.
95
98
When you open the console of your developer tools,
96
99
you should see ` Hello, <em>world</em>! `
97
100
98
- That’s it!
101
+ You probably also want to configure the target environment for the browsers
102
+ that you support.
103
+ That way,
104
+ JavaScript syntax which is too new for some browsers,
105
+ will be transformed into older JavaScript syntax that works.
106
+ Pass the [ ` --target ` ] [ esbuild-target ] flag to do this.
99
107
100
108
### CDN
101
109
@@ -134,4 +142,6 @@ you can use it in a browser like this:
134
142
135
143
[ esbuild ] : https://esbuild.github.io/
136
144
145
+ [ esbuild-target ] : https://esbuild.github.io/api/#target
146
+
137
147
[ esmsh ] : https://esm.sh/
You can’t perform that action at this time.
0 commit comments