Skip to content

Commit

Permalink
drop jquery.
Browse files Browse the repository at this point in the history
  • Loading branch information
yusuke-omae committed Sep 1, 2022
1 parent f2ca0b3 commit 539f968
Show file tree
Hide file tree
Showing 12 changed files with 345 additions and 246 deletions.
2 changes: 1 addition & 1 deletion .eslintrc.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
"parserOptions": { "sourceType": "module", "ecmaVersion": 2022 },
"overrides": [
{
"files": ["src/js/*.js"],
"files": ["src/js/*.mjs"],
"extends": ["eslint:recommended", "prettier"],
"parserOptions": {
"project": ["./tsconfig.json"]
Expand Down
2 changes: 1 addition & 1 deletion dist/js/lightbox.cjs

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion dist/js/lightbox.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion dist/js/lightbox.mjs

Large diffs are not rendered by default.

5 changes: 0 additions & 5 deletions examples/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -85,11 +85,6 @@ <h3>A Four Image Set</h3>
>
</p>
</section>
<script
src="https://code.jquery.com/jquery-3.6.1.min.js"
integrity="sha256-o88AwQnZB+VDvE9tvIXrMQaPlFFSUTR+nldQm1LuPXQ="
crossorigin="anonymous"
></script>
<script defer src="../dist/js/lightbox.js"></script>
</body>
</html>
17 changes: 11 additions & 6 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,16 @@
},
"exports": {
".": {
"import": "./dist/js/lightbox.mjs",
"require": "./dist/js/lightbox.cjs",
"node": {
"import": "./dist/js/lightbox.mjs",
"require": "./dist/js/lightbox.cjs",
"default": "./dist/js/lightbox.js"
},
"browser": {
"import": "./dist/js/lightbox.mjs",
"require": "./dist/js/lightbox.cjs",
"default": "./dist/js/lightbox.js"
},
"default": "./dist/js/lightbox.js"
},
"./css": "./dist/css/*.css",
Expand Down Expand Up @@ -56,7 +64,7 @@
"format:js": "prettier --write src/ts",
"lint": "run-p lint:*",
"lint:css": "stylelint src/css/lightbox.css",
"lint:js": "eslint src/js/*.js",
"lint:js": "eslint src/js/*.mjs",
"prebuild:js": "npm run clean:js",
"watch": "run-p watch:*",
"watch:css": "npm run build:css -- -w",
Expand All @@ -82,9 +90,6 @@
"stylelint-config-recess-order": "^3.0.0",
"stylelint-config-standard": "^26.0.0"
},
"peerDependencies": {
"jquery": "^3.0.0"
},
"browserslist": [
"> 1% and last 2 versions",
"not dead"
Expand Down
1 change: 0 additions & 1 deletion scripts/build.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@ const errors = [];
for (const result of results) {
if (result.status === 'rejected') {
errors.push(result.reason);
continue;
} else if (result.value.errors.length > 0) {
errors.push(...result.value.errors);
}
Expand Down
7 changes: 4 additions & 3 deletions scripts/config.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,8 @@ const browserslistPlugin = esbuildPluginBrowserslist(browserslist(), {

/** @type {BuildOptions} */
export const commonConfig = {
entryPoints: ['src/js/lightbox.js'],
outbase: 'src/js',
bundle: false,
bundle: true,
banner: {
js: `/*!
* Lightbox v2.11.2
Expand All @@ -32,13 +31,15 @@ export const commonConfig = {

/** @type {BuildOptions} */
export const esmConfig = {
entryPoints: ['src/js/lightbox.mjs'],
format: 'esm',
outfile: 'dist/js/lightbox.mjs',
plugins: [browserslistPlugin]
};

/** @type {BuildOptions} */
export const cjsConfig = {
entryPoints: ['src/js/lightbox.cjs'],
format: 'cjs',
platform: 'node',
outfile: 'dist/js/lightbox.cjs',
Expand All @@ -47,9 +48,9 @@ export const cjsConfig = {

/** @type {BuildOptions} */
export const browserConfig = {
entryPoints: ['src/js/browser.mjs'],
format: 'iife',
platform: 'browser',
globalName: 'lightbox',
outfile: 'dist/js/lightbox.js',
plugins: [browserslistPlugin]
};
Expand Down
14 changes: 5 additions & 9 deletions scripts/serve.mjs
Original file line number Diff line number Diff line change
@@ -1,17 +1,13 @@
import esbuild from 'esbuild';
import {
commonConfig,
esmConfig,
cjsConfig,
browserConfig,
serveConfig,
serveOptions
} from './config.mjs';

const config = { ...commonConfig, ...serveConfig };

await Promise.all([
esbuild.serve(serveOptions, { ...config, ...esmConfig }),
esbuild.serve(serveOptions, { ...config, ...cjsConfig }),
esbuild.serve(serveOptions, { ...config, ...browserConfig })
]);
await esbuild.serve(serveOptions, {
...commonConfig,
...serveConfig,
...browserConfig
});
2 changes: 2 additions & 0 deletions src/js/browser.mjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
import lightbox from './lightbox.mjs';
window.lightbox = lightbox;
2 changes: 2 additions & 0 deletions src/js/lightbox.cjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
const { lightbox } = require('./lightbox.mjs');
module.exports = lightbox;
Loading

0 comments on commit 539f968

Please sign in to comment.