jiek 0.1.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (106) hide show
  1. package/bin/jiek-dev.js +4 -0
  2. package/bin/jiek.js +2 -0
  3. package/dist/commands/build.esm.js +68 -0
  4. package/dist/commands/build.esm.js.map +1 -0
  5. package/dist/commands/build.esm.min.js +2 -0
  6. package/dist/commands/build.esm.min.js.map +1 -0
  7. package/dist/commands/publish.esm.js +60 -0
  8. package/dist/commands/publish.esm.js.map +1 -0
  9. package/dist/commands/publish.esm.min.js +2 -0
  10. package/dist/commands/publish.esm.min.js.map +1 -0
  11. package/dist/index.d.ts +2 -0
  12. package/dist/index.esm.d.ts +2 -0
  13. package/dist/index.esm.js +6 -0
  14. package/dist/index.esm.js.map +1 -0
  15. package/dist/index.esm.min.js +2 -0
  16. package/dist/index.esm.min.js.map +1 -0
  17. package/dist/index.iife.js +155 -0
  18. package/dist/index.iife.js.map +1 -0
  19. package/dist/index.iife.min.js +2 -0
  20. package/dist/index.iife.min.js.map +1 -0
  21. package/dist/index.umd.js +158 -0
  22. package/dist/index.umd.js.map +1 -0
  23. package/dist/index.umd.min.js +2 -0
  24. package/dist/index.umd.min.js.map +1 -0
  25. package/dist/inner.esm.js +10 -0
  26. package/dist/inner.esm.js.map +1 -0
  27. package/dist/inner.esm.min.js +2 -0
  28. package/dist/inner.esm.min.js.map +1 -0
  29. package/dist/merge-package-json.esm.js +16 -0
  30. package/dist/merge-package-json.esm.js.map +1 -0
  31. package/dist/merge-package-json.esm.min.js +2 -0
  32. package/dist/merge-package-json.esm.min.js.map +1 -0
  33. package/package.json +56 -0
  34. package/src/commands/build.ts +91 -0
  35. package/src/commands/publish.ts +79 -0
  36. package/src/index.ts +6 -0
  37. package/src/inner.ts +11 -0
  38. package/src/merge-package-json.ts +19 -0
  39. package/src/rollup/index.ts +162 -0
  40. package/src/rollup/plugins/globals.ts +34 -0
  41. package/src/rollup/plugins/skip.ts +23 -0
  42. package/src/rollup/utils/commonOptions.ts +9 -0
  43. package/src/rollup/utils/externalResolver.ts +11 -0
  44. package/src/rollup/utils/globalResolver.ts +24 -0
  45. package/src/rollup/utils/withMinify.ts +16 -0
  46. package/tests/build.spec.ts +28 -0
  47. package/tests/fixtures/node_modules/.bin/jiek +17 -0
  48. package/tests/fixtures/node_modules/.jiek/jiek+test-foo.rollup.config.js +31 -0
  49. package/tests/fixtures/node_modules/.modules.yaml +95 -0
  50. package/tests/fixtures/node_modules/.pnpm/@esbuild+darwin-arm64@0.20.2/node_modules/@esbuild/darwin-arm64/README.md +3 -0
  51. package/tests/fixtures/node_modules/.pnpm/@esbuild+darwin-arm64@0.20.2/node_modules/@esbuild/darwin-arm64/bin/esbuild +0 -0
  52. package/tests/fixtures/node_modules/.pnpm/@esbuild+darwin-arm64@0.20.2/node_modules/@esbuild/darwin-arm64/package.json +20 -0
  53. package/tests/fixtures/node_modules/.pnpm/@jiek+loader-esbuild@1.0.0_esbuild@0.20.2/node_modules/@jiek/loader-esbuild/LICENSE +21 -0
  54. package/tests/fixtures/node_modules/.pnpm/@jiek+loader-esbuild@1.0.0_esbuild@0.20.2/node_modules/@jiek/loader-esbuild/loader.js +3 -0
  55. package/tests/fixtures/node_modules/.pnpm/@jiek+loader-esbuild@1.0.0_esbuild@0.20.2/node_modules/@jiek/loader-esbuild/package.json +8 -0
  56. package/tests/fixtures/node_modules/.pnpm/debug@4.3.4/node_modules/debug/LICENSE +20 -0
  57. package/tests/fixtures/node_modules/.pnpm/debug@4.3.4/node_modules/debug/README.md +481 -0
  58. package/tests/fixtures/node_modules/.pnpm/debug@4.3.4/node_modules/debug/package.json +59 -0
  59. package/tests/fixtures/node_modules/.pnpm/debug@4.3.4/node_modules/debug/src/browser.js +269 -0
  60. package/tests/fixtures/node_modules/.pnpm/debug@4.3.4/node_modules/debug/src/common.js +274 -0
  61. package/tests/fixtures/node_modules/.pnpm/debug@4.3.4/node_modules/debug/src/index.js +10 -0
  62. package/tests/fixtures/node_modules/.pnpm/debug@4.3.4/node_modules/debug/src/node.js +263 -0
  63. package/tests/fixtures/node_modules/.pnpm/esbuild-register@3.5.0_esbuild@0.20.2/node_modules/esbuild-register/LICENSE +21 -0
  64. package/tests/fixtures/node_modules/.pnpm/esbuild-register@3.5.0_esbuild@0.20.2/node_modules/esbuild-register/README.md +50 -0
  65. package/tests/fixtures/node_modules/.pnpm/esbuild-register@3.5.0_esbuild@0.20.2/node_modules/esbuild-register/dist/loader.d.ts +3 -0
  66. package/tests/fixtures/node_modules/.pnpm/esbuild-register@3.5.0_esbuild@0.20.2/node_modules/esbuild-register/dist/loader.js +15 -0
  67. package/tests/fixtures/node_modules/.pnpm/esbuild-register@3.5.0_esbuild@0.20.2/node_modules/esbuild-register/dist/node.d.ts +23 -0
  68. package/tests/fixtures/node_modules/.pnpm/esbuild-register@3.5.0_esbuild@0.20.2/node_modules/esbuild-register/dist/node.js +4926 -0
  69. package/tests/fixtures/node_modules/.pnpm/esbuild-register@3.5.0_esbuild@0.20.2/node_modules/esbuild-register/loader.js +1 -0
  70. package/tests/fixtures/node_modules/.pnpm/esbuild-register@3.5.0_esbuild@0.20.2/node_modules/esbuild-register/node_modules/.bin/esbuild +14 -0
  71. package/tests/fixtures/node_modules/.pnpm/esbuild-register@3.5.0_esbuild@0.20.2/node_modules/esbuild-register/package.json +46 -0
  72. package/tests/fixtures/node_modules/.pnpm/esbuild-register@3.5.0_esbuild@0.20.2/node_modules/esbuild-register/register.js +3 -0
  73. package/tests/fixtures/node_modules/.pnpm/esbuild@0.20.2/node_modules/esbuild/LICENSE.md +21 -0
  74. package/tests/fixtures/node_modules/.pnpm/esbuild@0.20.2/node_modules/esbuild/README.md +3 -0
  75. package/tests/fixtures/node_modules/.pnpm/esbuild@0.20.2/node_modules/esbuild/bin/esbuild +0 -0
  76. package/tests/fixtures/node_modules/.pnpm/esbuild@0.20.2/node_modules/esbuild/install.js +288 -0
  77. package/tests/fixtures/node_modules/.pnpm/esbuild@0.20.2/node_modules/esbuild/lib/main.d.ts +703 -0
  78. package/tests/fixtures/node_modules/.pnpm/esbuild@0.20.2/node_modules/esbuild/lib/main.js +2436 -0
  79. package/tests/fixtures/node_modules/.pnpm/esbuild@0.20.2/node_modules/esbuild/node_modules/.bin/esbuild +14 -0
  80. package/tests/fixtures/node_modules/.pnpm/esbuild@0.20.2/node_modules/esbuild/package.json +46 -0
  81. package/tests/fixtures/node_modules/.pnpm/lock.yaml +291 -0
  82. package/tests/fixtures/node_modules/.pnpm/ms@2.1.2/node_modules/ms/index.js +162 -0
  83. package/tests/fixtures/node_modules/.pnpm/ms@2.1.2/node_modules/ms/license.md +21 -0
  84. package/tests/fixtures/node_modules/.pnpm/ms@2.1.2/node_modules/ms/package.json +37 -0
  85. package/tests/fixtures/node_modules/.pnpm/ms@2.1.2/node_modules/ms/readme.md +60 -0
  86. package/tests/fixtures/node_modules/.pnpm/node_modules/.bin/esbuild +14 -0
  87. package/tests/fixtures/package.json +8 -0
  88. package/tests/fixtures/packages/bar/package.json +4 -0
  89. package/tests/fixtures/packages/foo/dist/index.d.ts +3 -0
  90. package/tests/fixtures/packages/foo/dist/index.esm.d.ts +3 -0
  91. package/tests/fixtures/packages/foo/dist/index.esm.js +6 -0
  92. package/tests/fixtures/packages/foo/dist/index.esm.js.map +1 -0
  93. package/tests/fixtures/packages/foo/dist/index.esm.min.js +2 -0
  94. package/tests/fixtures/packages/foo/dist/index.esm.min.js.map +1 -0
  95. package/tests/fixtures/packages/foo/dist/index.iife.js +15 -0
  96. package/tests/fixtures/packages/foo/dist/index.iife.js.map +1 -0
  97. package/tests/fixtures/packages/foo/dist/index.iife.min.js +2 -0
  98. package/tests/fixtures/packages/foo/dist/index.iife.min.js.map +1 -0
  99. package/tests/fixtures/packages/foo/dist/index.umd.js +16 -0
  100. package/tests/fixtures/packages/foo/dist/index.umd.js.map +1 -0
  101. package/tests/fixtures/packages/foo/dist/index.umd.min.js +2 -0
  102. package/tests/fixtures/packages/foo/dist/index.umd.min.js.map +1 -0
  103. package/tests/fixtures/packages/foo/package.json +7 -0
  104. package/tests/fixtures/packages/foo/src/index.ts +3 -0
  105. package/tests/fixtures/pnpm-workspace.yaml +2 -0
  106. package/tests/publish.spec.ts +31 -0
@@ -0,0 +1,263 @@
1
+ /**
2
+ * Module dependencies.
3
+ */
4
+
5
+ const tty = require('tty');
6
+ const util = require('util');
7
+
8
+ /**
9
+ * This is the Node.js implementation of `debug()`.
10
+ */
11
+
12
+ exports.init = init;
13
+ exports.log = log;
14
+ exports.formatArgs = formatArgs;
15
+ exports.save = save;
16
+ exports.load = load;
17
+ exports.useColors = useColors;
18
+ exports.destroy = util.deprecate(
19
+ () => {},
20
+ 'Instance method `debug.destroy()` is deprecated and no longer does anything. It will be removed in the next major version of `debug`.'
21
+ );
22
+
23
+ /**
24
+ * Colors.
25
+ */
26
+
27
+ exports.colors = [6, 2, 3, 4, 5, 1];
28
+
29
+ try {
30
+ // Optional dependency (as in, doesn't need to be installed, NOT like optionalDependencies in package.json)
31
+ // eslint-disable-next-line import/no-extraneous-dependencies
32
+ const supportsColor = require('supports-color');
33
+
34
+ if (supportsColor && (supportsColor.stderr || supportsColor).level >= 2) {
35
+ exports.colors = [
36
+ 20,
37
+ 21,
38
+ 26,
39
+ 27,
40
+ 32,
41
+ 33,
42
+ 38,
43
+ 39,
44
+ 40,
45
+ 41,
46
+ 42,
47
+ 43,
48
+ 44,
49
+ 45,
50
+ 56,
51
+ 57,
52
+ 62,
53
+ 63,
54
+ 68,
55
+ 69,
56
+ 74,
57
+ 75,
58
+ 76,
59
+ 77,
60
+ 78,
61
+ 79,
62
+ 80,
63
+ 81,
64
+ 92,
65
+ 93,
66
+ 98,
67
+ 99,
68
+ 112,
69
+ 113,
70
+ 128,
71
+ 129,
72
+ 134,
73
+ 135,
74
+ 148,
75
+ 149,
76
+ 160,
77
+ 161,
78
+ 162,
79
+ 163,
80
+ 164,
81
+ 165,
82
+ 166,
83
+ 167,
84
+ 168,
85
+ 169,
86
+ 170,
87
+ 171,
88
+ 172,
89
+ 173,
90
+ 178,
91
+ 179,
92
+ 184,
93
+ 185,
94
+ 196,
95
+ 197,
96
+ 198,
97
+ 199,
98
+ 200,
99
+ 201,
100
+ 202,
101
+ 203,
102
+ 204,
103
+ 205,
104
+ 206,
105
+ 207,
106
+ 208,
107
+ 209,
108
+ 214,
109
+ 215,
110
+ 220,
111
+ 221
112
+ ];
113
+ }
114
+ } catch (error) {
115
+ // Swallow - we only care if `supports-color` is available; it doesn't have to be.
116
+ }
117
+
118
+ /**
119
+ * Build up the default `inspectOpts` object from the environment variables.
120
+ *
121
+ * $ DEBUG_COLORS=no DEBUG_DEPTH=10 DEBUG_SHOW_HIDDEN=enabled node script.js
122
+ */
123
+
124
+ exports.inspectOpts = Object.keys(process.env).filter(key => {
125
+ return /^debug_/i.test(key);
126
+ }).reduce((obj, key) => {
127
+ // Camel-case
128
+ const prop = key
129
+ .substring(6)
130
+ .toLowerCase()
131
+ .replace(/_([a-z])/g, (_, k) => {
132
+ return k.toUpperCase();
133
+ });
134
+
135
+ // Coerce string value into JS value
136
+ let val = process.env[key];
137
+ if (/^(yes|on|true|enabled)$/i.test(val)) {
138
+ val = true;
139
+ } else if (/^(no|off|false|disabled)$/i.test(val)) {
140
+ val = false;
141
+ } else if (val === 'null') {
142
+ val = null;
143
+ } else {
144
+ val = Number(val);
145
+ }
146
+
147
+ obj[prop] = val;
148
+ return obj;
149
+ }, {});
150
+
151
+ /**
152
+ * Is stdout a TTY? Colored output is enabled when `true`.
153
+ */
154
+
155
+ function useColors() {
156
+ return 'colors' in exports.inspectOpts ?
157
+ Boolean(exports.inspectOpts.colors) :
158
+ tty.isatty(process.stderr.fd);
159
+ }
160
+
161
+ /**
162
+ * Adds ANSI color escape codes if enabled.
163
+ *
164
+ * @api public
165
+ */
166
+
167
+ function formatArgs(args) {
168
+ const {namespace: name, useColors} = this;
169
+
170
+ if (useColors) {
171
+ const c = this.color;
172
+ const colorCode = '\u001B[3' + (c < 8 ? c : '8;5;' + c);
173
+ const prefix = ` ${colorCode};1m${name} \u001B[0m`;
174
+
175
+ args[0] = prefix + args[0].split('\n').join('\n' + prefix);
176
+ args.push(colorCode + 'm+' + module.exports.humanize(this.diff) + '\u001B[0m');
177
+ } else {
178
+ args[0] = getDate() + name + ' ' + args[0];
179
+ }
180
+ }
181
+
182
+ function getDate() {
183
+ if (exports.inspectOpts.hideDate) {
184
+ return '';
185
+ }
186
+ return new Date().toISOString() + ' ';
187
+ }
188
+
189
+ /**
190
+ * Invokes `util.format()` with the specified arguments and writes to stderr.
191
+ */
192
+
193
+ function log(...args) {
194
+ return process.stderr.write(util.format(...args) + '\n');
195
+ }
196
+
197
+ /**
198
+ * Save `namespaces`.
199
+ *
200
+ * @param {String} namespaces
201
+ * @api private
202
+ */
203
+ function save(namespaces) {
204
+ if (namespaces) {
205
+ process.env.DEBUG = namespaces;
206
+ } else {
207
+ // If you set a process.env field to null or undefined, it gets cast to the
208
+ // string 'null' or 'undefined'. Just delete instead.
209
+ delete process.env.DEBUG;
210
+ }
211
+ }
212
+
213
+ /**
214
+ * Load `namespaces`.
215
+ *
216
+ * @return {String} returns the previously persisted debug modes
217
+ * @api private
218
+ */
219
+
220
+ function load() {
221
+ return process.env.DEBUG;
222
+ }
223
+
224
+ /**
225
+ * Init logic for `debug` instances.
226
+ *
227
+ * Create a new `inspectOpts` object in case `useColors` is set
228
+ * differently for a particular `debug` instance.
229
+ */
230
+
231
+ function init(debug) {
232
+ debug.inspectOpts = {};
233
+
234
+ const keys = Object.keys(exports.inspectOpts);
235
+ for (let i = 0; i < keys.length; i++) {
236
+ debug.inspectOpts[keys[i]] = exports.inspectOpts[keys[i]];
237
+ }
238
+ }
239
+
240
+ module.exports = require('./common')(exports);
241
+
242
+ const {formatters} = module.exports;
243
+
244
+ /**
245
+ * Map %o to `util.inspect()`, all on a single line.
246
+ */
247
+
248
+ formatters.o = function (v) {
249
+ this.inspectOpts.colors = this.useColors;
250
+ return util.inspect(v, this.inspectOpts)
251
+ .split('\n')
252
+ .map(str => str.trim())
253
+ .join(' ');
254
+ };
255
+
256
+ /**
257
+ * Map %O to `util.inspect()`, allowing multiple lines if needed.
258
+ */
259
+
260
+ formatters.O = function (v) {
261
+ this.inspectOpts.colors = this.useColors;
262
+ return util.inspect(v, this.inspectOpts);
263
+ };
@@ -0,0 +1,21 @@
1
+ The MIT License (MIT)
2
+
3
+ Copyright (c) EGOIST <0x142857@gmail.com> (https://egoist.sh)
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in
13
+ all copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
21
+ THE SOFTWARE.
@@ -0,0 +1,50 @@
1
+ # esbuild-register
2
+
3
+ [![npm version](https://badgen.net/npm/v/esbuild-register)](https://npm.im/esbuild-register) [![npm downloads](https://badgen.net/npm/dm/esbuild-register)](https://npm.im/esbuild-register)
4
+
5
+ ## Install
6
+
7
+ ```bash
8
+ npm i esbuild esbuild-register -D
9
+ # Or Yarn
10
+ yarn add esbuild esbuild-register --dev
11
+ # Or pnpm
12
+ pnpm add esbuild esbuild-register -D
13
+ ```
14
+
15
+ ## Usage
16
+
17
+ ```bash
18
+ node -r esbuild-register file.ts
19
+ ```
20
+
21
+ It will use `jsxFactory`, `jsxFragmentFactory` and `target` options from your `tsconfig.json`
22
+
23
+ ### Experimental loader support
24
+
25
+ When using in a project with `type: "module"` in `package.json`, you need the `--loader` flag to load TypeScript files:
26
+
27
+ ```bash
28
+ node --loader esbuild-register/loader -r esbuild-register ./file.ts
29
+ ```
30
+
31
+ ## Programmatic Usage
32
+
33
+ ```ts
34
+ const { register } = require('esbuild-register/dist/node')
35
+
36
+ const { unregister } = register({
37
+ // ...options
38
+ })
39
+
40
+ // Unregister the require hook if you don't need it anymore
41
+ unregister()
42
+ ```
43
+
44
+ ## Sponsors
45
+
46
+ [![sponsors](https://sponsors-images.egoist.dev/sponsors.svg)](https://github.com/sponsors/egoist)
47
+
48
+ ## License
49
+
50
+ MIT &copy; [EGOIST](https://egoist.dev)
@@ -0,0 +1,3 @@
1
+ declare function load(url: any, context: any, defaultLoad: any): Promise<any>;
2
+
3
+ export { load };
@@ -0,0 +1,15 @@
1
+ "use strict";Object.defineProperty(exports, "__esModule", {value: true});// src/loader.ts
2
+ var extensionsRegex = /\.(ts|tsx|mts|cts)$/;
3
+ async function load(url, context, defaultLoad) {
4
+ if (extensionsRegex.test(url)) {
5
+ const {source} = await defaultLoad(url, {format: "module"});
6
+ return {
7
+ format: "commonjs",
8
+ source
9
+ };
10
+ }
11
+ return defaultLoad(url, context, defaultLoad);
12
+ }
13
+
14
+
15
+ exports.load = load;
@@ -0,0 +1,23 @@
1
+ import { TransformOptions } from 'esbuild';
2
+
3
+ declare type LOADERS = 'js' | 'jsx' | 'ts' | 'tsx';
4
+ declare const FILE_LOADERS: Record<string, LOADERS>;
5
+ declare type EXTENSIONS = keyof typeof FILE_LOADERS;
6
+ interface RegisterOptions extends TransformOptions {
7
+ extensions?: EXTENSIONS[];
8
+ /**
9
+ * Auto-ignore node_modules. Independent of any matcher.
10
+ * @default true
11
+ */
12
+ hookIgnoreNodeModules?: boolean;
13
+ /**
14
+ * A matcher function, will be called with path to a file. Should return truthy if the file should be hooked, falsy otherwise.
15
+ */
16
+ hookMatcher?(fileName: string): boolean;
17
+ }
18
+ declare function register(esbuildOptions?: RegisterOptions): {
19
+ unregister(): void;
20
+ };
21
+ declare type Register = ReturnType<typeof register>;
22
+
23
+ export { Register, register };