proscenium 0.1.0.alpha2-arm64-darwin → 0.1.0.alpha3-arm64-darwin

Sign up to get free protection for your applications and to get access to all the features.
Files changed (35) hide show
  1. checksums.yaml +4 -4
  2. data/README.md +158 -29
  3. data/bin/esbuild +0 -0
  4. data/bin/parcel_css +0 -0
  5. data/config/routes.rb +1 -1
  6. data/lib/proscenium/compilers/esbuild/compile_error.js +145 -0
  7. data/lib/proscenium/compilers/esbuild/css_plugin.js +76 -0
  8. data/lib/proscenium/compilers/esbuild/env_plugin.js +6 -4
  9. data/lib/proscenium/compilers/esbuild/http_bundle_plugin.js +53 -0
  10. data/lib/proscenium/compilers/esbuild/import_map.js +59 -0
  11. data/lib/proscenium/compilers/esbuild/resolve_plugin.js +38 -35
  12. data/lib/proscenium/compilers/esbuild/setup_plugin.js +23 -22
  13. data/lib/proscenium/{cli → compilers}/esbuild/solidjs_plugin.js +5 -4
  14. data/lib/proscenium/compilers/esbuild.bench.js +7 -3
  15. data/lib/proscenium/compilers/esbuild.js +60 -19
  16. data/lib/proscenium/helper.rb +2 -2
  17. data/lib/proscenium/middleware/base.rb +13 -3
  18. data/lib/proscenium/middleware/esbuild.rb +14 -0
  19. data/lib/proscenium/middleware/parcel_css.rb +30 -3
  20. data/lib/proscenium/middleware.rb +3 -0
  21. data/lib/proscenium/railtie.rb +16 -18
  22. data/lib/proscenium/runtime/component_manager/index.js +7 -7
  23. data/lib/proscenium/runtime/component_manager/{render_component.js → render_component.jsx} +9 -13
  24. data/lib/proscenium/version.rb +1 -1
  25. metadata +8 -14
  26. data/lib/proscenium/cli/argument_error.js +0 -24
  27. data/lib/proscenium/cli/builders/index.js +0 -1
  28. data/lib/proscenium/cli/builders/javascript.js +0 -45
  29. data/lib/proscenium/cli/builders/react.js +0 -60
  30. data/lib/proscenium/cli/builders/solid.js +0 -46
  31. data/lib/proscenium/cli/esbuild/env_plugin.js +0 -21
  32. data/lib/proscenium/cli/esbuild/resolve_plugin.js +0 -136
  33. data/lib/proscenium/cli/js_builder.js +0 -194
  34. data/lib/proscenium/cli/solid.js +0 -15
  35. data/lib/proscenium/cli/utils.js +0 -93
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: proscenium
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.0.alpha2
4
+ version: 0.1.0.alpha3
5
5
  platform: arm64-darwin
6
6
  authors:
7
7
  - Joel Moss
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2022-07-26 00:00:00.000000000 Z
11
+ date: 2022-08-10 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: actioncable
@@ -132,24 +132,18 @@ files:
132
132
  - bin/parcel_css
133
133
  - config/routes.rb
134
134
  - lib/proscenium.rb
135
- - lib/proscenium/cli/argument_error.js
136
- - lib/proscenium/cli/builders/index.js
137
- - lib/proscenium/cli/builders/javascript.js
138
- - lib/proscenium/cli/builders/react.js
139
- - lib/proscenium/cli/builders/solid.js
140
- - lib/proscenium/cli/esbuild/env_plugin.js
141
- - lib/proscenium/cli/esbuild/resolve_plugin.js
142
- - lib/proscenium/cli/esbuild/solidjs_plugin.js
143
- - lib/proscenium/cli/js_builder.js
144
- - lib/proscenium/cli/solid.js
145
- - lib/proscenium/cli/utils.js
146
135
  - lib/proscenium/compiler.js
147
136
  - lib/proscenium/compilers/esbuild.bench.js
148
137
  - lib/proscenium/compilers/esbuild.js
149
138
  - lib/proscenium/compilers/esbuild/argument_error.js
139
+ - lib/proscenium/compilers/esbuild/compile_error.js
140
+ - lib/proscenium/compilers/esbuild/css_plugin.js
150
141
  - lib/proscenium/compilers/esbuild/env_plugin.js
142
+ - lib/proscenium/compilers/esbuild/http_bundle_plugin.js
143
+ - lib/proscenium/compilers/esbuild/import_map.js
151
144
  - lib/proscenium/compilers/esbuild/resolve_plugin.js
152
145
  - lib/proscenium/compilers/esbuild/setup_plugin.js
146
+ - lib/proscenium/compilers/esbuild/solidjs_plugin.js
153
147
  - lib/proscenium/css_module.rb
154
148
  - lib/proscenium/current.rb
155
149
  - lib/proscenium/helper.rb
@@ -164,7 +158,7 @@ files:
164
158
  - lib/proscenium/railtie.rb
165
159
  - lib/proscenium/runtime/auto_reload.js
166
160
  - lib/proscenium/runtime/component_manager/index.js
167
- - lib/proscenium/runtime/component_manager/render_component.js
161
+ - lib/proscenium/runtime/component_manager/render_component.jsx
168
162
  - lib/proscenium/runtime/import_css.js
169
163
  - lib/proscenium/runtime/react_shim/index.js
170
164
  - lib/proscenium/runtime/react_shim/package.json
@@ -1,24 +0,0 @@
1
- export default class CliArgumentError extends Error {
2
- static MESSAGES = {
3
- cwdRequired: 'Current working directory is required as first argument.',
4
- entrypointRequired: 'An entry point is required as second argument.',
5
- builderRequired: 'The builder is required as third and final argument.',
6
-
7
- cwdUnknown: ({ cwd }) => `A valid working directory is required - received ${cwd}`,
8
- entrypointUnknown: ({ entrypoint }) =>
9
- `A valid entrypoint is required - received ${entrypoint}`,
10
- builderUnknown: ({ builder }) => `Unknown builder '${builder}'`
11
- }
12
-
13
- constructor(reason, options) {
14
- let message = CliArgumentError.MESSAGES[reason]
15
- if (typeof message === 'function') {
16
- message = message(options)
17
- }
18
-
19
- super(message, options)
20
-
21
- this.reason = reason
22
- this.message = message
23
- }
24
- }
@@ -1 +0,0 @@
1
- export const builderNames = ['javascript', 'react', 'solid']
@@ -1,45 +0,0 @@
1
- import { build, stop } from 'esbuild'
2
-
3
- import envPlugin from '../esbuild/env_plugin.js'
4
- import resolvePlugin from '../esbuild/resolve_plugin.js'
5
-
6
- export default async (cwd, entrypoint) => {
7
- const railsEnv = Deno.env.get('RAILS_ENV')
8
- const isProd = railsEnv === 'production'
9
-
10
- let entrypointIsSourcemap = false
11
- if (/\.js\.map$/.test(entrypoint)) {
12
- entrypoint = entrypoint.replace(/\.map$/, '')
13
- entrypointIsSourcemap = true
14
- }
15
-
16
- const params = {
17
- entryPoints: [entrypoint],
18
- absWorkingDir: cwd,
19
- logLevel: 'error',
20
- sourcemap: !entrypointIsSourcemap ? false : 'linked',
21
- outdir: 'public',
22
- outbase: './',
23
- write: false,
24
- format: 'esm',
25
- minify: isProd,
26
- bundle: true,
27
- plugins: [envPlugin(), resolvePlugin({ debug: false })]
28
- }
29
-
30
- try {
31
- const result = await build(params)
32
-
33
- if (params.sourcemap === 'linked') {
34
- if (entrypointIsSourcemap) {
35
- return result.outputFiles[0].contents
36
- } else {
37
- return result.outputFiles[1].contents
38
- }
39
- } else {
40
- return result.outputFiles[0].contents
41
- }
42
- } finally {
43
- stop()
44
- }
45
- }
@@ -1,60 +0,0 @@
1
- import { build, stop } from 'esbuild'
2
- import { join } from 'std/path/mod.ts'
3
-
4
- import envPlugin from '../esbuild/env_plugin.js'
5
- import resolvePlugin from '../esbuild/resolve_plugin.js'
6
-
7
- export default async (cwd, entrypoint) => {
8
- const railsEnv = Deno.env.get('RAILS_ENV')
9
- const isProd = railsEnv === 'production'
10
-
11
- let entrypointIsSourcemap = false
12
- if (/\.jsx\.map$/.test(entrypoint)) {
13
- entrypoint = entrypoint.replace(/\.map$/, '')
14
- entrypointIsSourcemap = true
15
- }
16
-
17
- const params = {
18
- entryPoints: [entrypoint],
19
- absWorkingDir: cwd,
20
- logLevel: 'error',
21
- sourcemap: !entrypointIsSourcemap ? false : 'linked',
22
- outdir: 'public',
23
- outbase: './',
24
- write: false,
25
- format: 'esm',
26
- minify: isProd,
27
- bundle: true,
28
- // jsxFactory: 'createElement',
29
- // jsxFragment: 'Fragment',
30
- plugins: [envPlugin(), resolvePlugin({ debug: false })]
31
- }
32
-
33
- if (entrypoint.endsWith('.jsx')) {
34
- try {
35
- const stat = Deno.lstatSync(join(cwd, 'lib/react_shim.js'))
36
- if (stat.isFile) {
37
- params.inject = ['./lib/react_shim.js']
38
- }
39
- } catch {
40
- // Safe to swallow as this should only throw if file does not exist.
41
- // TODO: print warning to user
42
- }
43
- }
44
-
45
- try {
46
- const result = await build(params)
47
-
48
- if (params.sourcemap === 'linked') {
49
- if (entrypointIsSourcemap) {
50
- return result.outputFiles[0].contents
51
- } else {
52
- return result.outputFiles[1].contents
53
- }
54
- } else {
55
- return result.outputFiles[0].contents
56
- }
57
- } finally {
58
- stop()
59
- }
60
- }
@@ -1,46 +0,0 @@
1
- import { build, stop } from 'esbuild'
2
-
3
- import envPlugin from '../esbuild/env_plugin.js'
4
- import resolvePlugin from '../esbuild/resolve_plugin.js'
5
- import solidjsPlugin from '../esbuild/solidjs_plugin.js'
6
-
7
- export default async (cwd, entrypoint) => {
8
- const railsEnv = Deno.env.get('RAILS_ENV')
9
- const isProd = railsEnv === 'production'
10
-
11
- let entrypointIsSourcemap = false
12
- if (/\.jsx\.map$/.test(entrypoint)) {
13
- entrypoint = entrypoint.replace(/\.map$/, '')
14
- entrypointIsSourcemap = true
15
- }
16
-
17
- const params = {
18
- entryPoints: [entrypoint],
19
- absWorkingDir: cwd,
20
- logLevel: 'error',
21
- sourcemap: !entrypointIsSourcemap ? false : 'linked',
22
- outdir: 'public',
23
- outbase: './',
24
- write: false,
25
- format: 'esm',
26
- minify: isProd,
27
- bundle: true,
28
- plugins: [envPlugin(), resolvePlugin({ debug: false }), solidjsPlugin({ debug: false })]
29
- }
30
-
31
- try {
32
- const result = await build(params)
33
-
34
- if (params.sourcemap === 'linked') {
35
- if (entrypointIsSourcemap) {
36
- return result.outputFiles[0].contents
37
- } else {
38
- return result.outputFiles[1].contents
39
- }
40
- } else {
41
- return result.outputFiles[0].contents
42
- }
43
- } finally {
44
- stop()
45
- }
46
- }
@@ -1,21 +0,0 @@
1
- import { setup } from '../utils.js'
2
-
3
- export default setup('env', () => {
4
- return {
5
- onResolve: {
6
- filter: /^env$/,
7
- callback({ path }) {
8
- return { path, namespace: 'env' }
9
- }
10
- },
11
-
12
- onLoad: {
13
- filter: /.*/,
14
- namespace: 'env',
15
- callback() {
16
- const env = Deno.env.toObject()
17
- return { loader: 'json', contents: JSON.stringify(env) }
18
- }
19
- }
20
- }
21
- })
@@ -1,136 +0,0 @@
1
- import { join, resolve } from 'std/path/mod.ts'
2
- import {
3
- parseFromString as parseImportMap,
4
- resolve as resolveFromImportMap
5
- } from 'import-maps/resolve'
6
-
7
- import { setup } from '../utils.js'
8
-
9
- const baseURL = new URL('file://')
10
- const importKinds = ['import-statement', 'dynamic-import', 'require-call']
11
-
12
- export default setup('resolve', build => {
13
- const cwd = build.initialOptions.absWorkingDir
14
- const importMap = readImportMap()
15
-
16
- return {
17
- onResolve: {
18
- filter: /.*/,
19
- async callback(args) {
20
- // Remote modules
21
- if (args.path.startsWith('http://') || args.path.startsWith('https://')) {
22
- return { external: true }
23
- }
24
-
25
- // Proscenium runtime
26
- if (args.path.startsWith('/proscenium-runtime')) {
27
- return { external: true }
28
- }
29
-
30
- // Everything else is unbundled.
31
- if (importKinds.includes(args.kind)) {
32
- return await unbundleImport(args)
33
- }
34
- }
35
- },
36
-
37
- onLoad: {
38
- filter: /.*/,
39
- namespace: 'importStylesheet',
40
- callback(args) {
41
- const result = {
42
- resolveDir: cwd,
43
- loader: 'js'
44
- }
45
-
46
- if (args.path.endsWith('.module.css')) {
47
- result.contents = `
48
- import { importCssModule } from '/proscenium-runtime/import_css.js'
49
- export default await importCssModule('${args.path}')
50
- `
51
- } else {
52
- result.contents = `
53
- import { appendStylesheet } from '/proscenium-runtime/import_css.js'
54
- appendStylesheet('${args.path}')
55
- `
56
- }
57
-
58
- return result
59
- }
60
- }
61
- }
62
-
63
- // Resolve the given `params.path` to a path relative to the Rails root.
64
- //
65
- // Examples:
66
- // 'react' -> '/.../node_modules/react/index.js'
67
- // './my_module' -> '/.../app/my_module.js'
68
- // '/app/my_module' -> '/.../app/my_module.js'
69
- async function unbundleImport(params) {
70
- const result = { path: params.path }
71
-
72
- if (importMap) {
73
- const { matched, resolvedImport } = resolveFromImportMap(params.path, importMap, baseURL)
74
- if (matched) {
75
- if (resolvedImport.protocol === 'file:') {
76
- params.path = resolvedImport.pathname
77
- } else {
78
- return { path: resolvedImport.href, external: true }
79
- }
80
- }
81
- }
82
-
83
- // Absolute path - append to current working dir.
84
- if (params.path.startsWith('/')) {
85
- result.path = resolve(cwd, params.path.slice(1))
86
- }
87
-
88
- // Resolve the path using esbuild's internal resolution. This allows us to import node packages
89
- // and extension-less paths without custom code, as esbuild with resolve them for us.
90
- const resolveResult = await build.resolve(result.path, {
91
- resolveDir: params.resolveDir,
92
- pluginData: {
93
- // We use this property later on, as we should ignore this resolution call.
94
- isResolvingPath: true
95
- }
96
- })
97
-
98
- if (resolveResult.errors.length > 0) {
99
- // throw `${resolveResult.errors[0].text} (resolveDir: ${cwd})`
100
- }
101
-
102
- result.path = resolveResult.path.slice(cwd.length)
103
- result.sideEffects = resolveResult.sideEffects
104
-
105
- if (
106
- params.path.endsWith('.css') &&
107
- params.kind === 'import-statement' &&
108
- /\.jsx?$/.test(params.importer)
109
- ) {
110
- // We're importing a CSS file from JS(X).
111
- result.namespace = 'importStylesheet'
112
- } else {
113
- // Requested path is a bare module.
114
- result.external = true
115
- }
116
-
117
- return result
118
- }
119
-
120
- function readImportMap() {
121
- const file = join(cwd, 'config', 'import_map.json')
122
- let source
123
-
124
- try {
125
- source = Deno.readTextFileSync(file)
126
- } catch {
127
- return null
128
- }
129
-
130
- return parseImportMap(source, baseURL)
131
- }
132
- })
133
-
134
- function isBareModule(path) {
135
- return !path.startsWith('.') && !path.startsWith('/')
136
- }
@@ -1,194 +0,0 @@
1
- import * as esbuild from 'https://deno.land/x/esbuild@v0.14.27/mod.js'
2
- import { parse } from 'flags/mod.ts'
3
- import { join } from 'path/mod.ts'
4
-
5
- import resolvePlugin from './esbuild/resolve_plugin.js'
6
-
7
- const isProd = Deno.env.get('RAILS_ENV') === 'production'
8
- const isTest = Deno.env.get('RAILS_ENV') === 'test'
9
- const template = `
10
- <style>
11
- :host {
12
- position: fixed;
13
- z-index: 99999;
14
- top: 0;
15
- left: 0;
16
- width: 100%;
17
- height: 100%;
18
- overflow-y: scroll;
19
- margin: 0;
20
- background: rgba(0, 0, 0, 0.66);
21
- display: flex;
22
- align-items: center;
23
- --monospace: 'SFMono-Regular', Consolas,
24
- 'Liberation Mono', Menlo, Courier, monospace;
25
- --red: #ff5555;
26
- --yellow: #e2aa53;
27
- --purple: #cfa4ff;
28
- --cyan: #2dd9da;
29
- --dim: #c9c9c9;
30
- }
31
-
32
- .window {
33
- font-family: var(--monospace);
34
- line-height: 1.5;
35
- width: 800px;
36
- color: #d8d8d8;
37
- margin: 30px auto;
38
- padding: 25px 40px;
39
- position: relative;
40
- background: #181818;
41
- border-radius: 6px 6px 8px 8px;
42
- box-shadow: 0 19px 38px rgba(0,0,0,0.30), 0 15px 12px rgba(0,0,0,0.22);
43
- overflow: hidden;
44
- border-top: 8px solid var(--red);
45
- }
46
-
47
- pre {
48
- font-family: var(--monospace);
49
- font-size: 16px;
50
- margin-top: 0;
51
- margin-bottom: 1em;
52
- overflow-x: scroll;
53
- scrollbar-width: none;
54
- }
55
-
56
- pre::-webkit-scrollbar {
57
- display: none;
58
- }
59
-
60
- .message {
61
- line-height: 1.3;
62
- font-weight: 600;
63
- white-space: pre-wrap;
64
- }
65
-
66
- .message-body {
67
- color: var(--red);
68
- }
69
-
70
- .file {
71
- color: var(--cyan);
72
- margin-bottom: 0;
73
- white-space: pre-wrap;
74
- word-break: break-all;
75
- }
76
-
77
- </style>
78
- <div class="window">
79
- <pre class="message"><span class="message-body"></span></pre>
80
- <pre class="file"></pre>
81
- </div>
82
- `
83
-
84
- export default async (args, { debug }) => {
85
- const { _: entrypoints, ...flags } = parse(args)
86
- const [cwd, entrypoint] = validatePaths(entrypoints)
87
-
88
- const params = {
89
- entryPoints: [entrypoint],
90
- absWorkingDir: cwd,
91
- logLevel: 'error',
92
- sourcemap: isTest ? false : 'inline',
93
- write: false,
94
- format: 'esm',
95
- // minify: true,
96
- bundle: true,
97
- plugins: [resolvePlugin({ debug })]
98
- }
99
-
100
- if (entrypoint.endsWith('.jsx')) {
101
- try {
102
- const stat = Deno.lstatSync(join(cwd, 'lib/react_shim.js'))
103
- if (stat.isFile) {
104
- params.inject = ['./lib/react_shim.js']
105
- }
106
- } catch {
107
- // Safe to swallow as this should only throw if file does not exist.
108
- }
109
- }
110
-
111
- try {
112
- const result = await esbuild.build(params)
113
- return result.outputFiles[0].contents
114
-
115
- // } catch (e) {
116
- // if (isProd) {
117
- // return new TextEncoder().encode(`
118
- // const err = ${JSON.stringify(e.errors[0])}
119
- // const location = \`\${err.location.file}:\${err.location.line}:\${err.location.column}\`
120
- // console.error('%s at %O', err.text, location);
121
- // `)
122
- // } else {
123
- // return new TextEncoder().encode(`
124
- // class ErrorOverlay extends HTMLElement {
125
- // constructor(err) {
126
- // super()
127
-
128
- // this.root = this.attachShadow({ mode: 'open' })
129
- // this.root.innerHTML = \`${template}\`
130
- // this.root.querySelector('.message-body').textContent = err.text.trim()
131
-
132
- // if (err.location) {
133
- // const location = \`\${err.location.file}:\${err.location.line}:\${err.location.column}\`
134
- // this.root.querySelector('.file').textContent = location
135
- // console.error('%s at %O', err.text, location)
136
- // } else {
137
- // console.error(err.text)
138
- // }
139
-
140
- // throw err
141
- // }
142
- // }
143
-
144
- // customElements.define('error-overlay', ErrorOverlay)
145
- // document.body.appendChild(new ErrorOverlay(${JSON.stringify(e.errors[0])}))
146
- // `)
147
- // }
148
- } finally {
149
- esbuild.stop()
150
- }
151
- }
152
-
153
- function validatePaths(paths) {
154
- const cwd = paths[0]
155
- const entrypoint = paths[1]
156
-
157
- if (!cwd || !entrypoint) {
158
- throw new TypeError(
159
- 'Current working directory and entrypoint are required as first and second arguments.'
160
- )
161
- }
162
-
163
- try {
164
- const stat = Deno.lstatSync(cwd)
165
- if (!stat.isDirectory) {
166
- throw new TypeError(
167
- `Current working directory is required as the first argument - received ${cwd}`
168
- )
169
- }
170
- } catch {
171
- throw new TypeError(
172
- `A valid working directory is required as the first argument - received ${cwd}`
173
- )
174
- }
175
-
176
- try {
177
- const stat = Deno.lstatSync(join(cwd, entrypoint))
178
- if (!stat.isFile) {
179
- throw new TypeError(`Entrypoint is required as the second argument - received ${entrypoint}`)
180
- }
181
- } catch {
182
- throw new TypeError(
183
- `A valid entrypoint is required as the second argument - received ${entrypoint}`
184
- )
185
- }
186
-
187
- if (/\.(js|jsx)$/.test(entrypoint) === false) {
188
- throw new TypeError(
189
- `Only a JS/JSX entrypoint is supported with this CLI - received ${entrypoint}`
190
- )
191
- }
192
-
193
- return [cwd, entrypoint]
194
- }
@@ -1,15 +0,0 @@
1
- import { writeAll } from 'std/streams/mod.ts'
2
- import { parseArgs } from './utils.js'
3
-
4
- import builder from './builders/solid.js'
5
-
6
- if (import.meta.main) {
7
- await writeAll(Deno.stdout, await main(Deno.args))
8
- }
9
-
10
- async function main(args = []) {
11
- const [cwd, entrypoint, _] = parseArgs(args)
12
- return await builder(cwd, entrypoint)
13
- }
14
-
15
- export default main
@@ -1,93 +0,0 @@
1
- import { join } from 'std/path/mod.ts'
2
-
3
- import CliArgumentError from './argument_error.js'
4
- import { builderNames } from './builders/index.js'
5
-
6
- export const isTest = () => Deno.env.get('ENVIRONMENT') === 'test'
7
-
8
- export const debug = (...args) => {
9
- isTest() && console.log(...args)
10
- }
11
-
12
- export const setup = (pluginName, pluginFn) => {
13
- return (options = {}) => ({
14
- name: pluginName,
15
- setup(build) {
16
- const plugin = pluginFn(build)
17
-
18
- if (plugin.onResolve) {
19
- const { callback, ...onResolve } = plugin.onResolve
20
-
21
- build.onResolve(onResolve, async params => {
22
- if (params.pluginData?.isResolvingPath) return
23
-
24
- const results = await callback(params)
25
-
26
- options.debug && console.debug(`plugin(${pluginName}:onResolve)`, { params, results })
27
-
28
- return results
29
- })
30
- }
31
-
32
- if (plugin.onLoad) {
33
- const { callback, ...onLoad } = plugin.onLoad
34
-
35
- build.onLoad(onLoad, params => {
36
- const results = callback(params)
37
-
38
- options.debug && console.debug(`plugin(${pluginName}:onLoad)`, { params, results })
39
-
40
- return results
41
- })
42
- }
43
- }
44
- })
45
- }
46
-
47
- export const parseArgs = args => {
48
- let [cwd, entrypoint, builder] = args
49
-
50
- if (!cwd) {
51
- throw new CliArgumentError('cwdRequired')
52
- }
53
-
54
- if (!entrypoint) {
55
- throw new CliArgumentError('entrypointRequired')
56
- }
57
-
58
- if (!builder) {
59
- throw new CliArgumentError('builderRequired')
60
- }
61
-
62
- try {
63
- const stat = Deno.lstatSync(cwd)
64
- if (!stat.isDirectory) {
65
- throw new CliArgumentError(
66
- `Current working directory is required as the first argument - received ${cwd}`
67
- )
68
- }
69
- } catch {
70
- throw new CliArgumentError('cwdUnknown', { cwd })
71
- }
72
-
73
- if (/\.(jsx?)|(css)\.map$/.test(entrypoint)) {
74
- entrypoint = entrypoint.replace(/\.map$/, '')
75
- }
76
-
77
- try {
78
- const stat = Deno.lstatSync(join(cwd, entrypoint))
79
- if (!stat.isFile) {
80
- throw new CliArgumentError(
81
- `Entrypoint is required as the second argument - received ${entrypoint}`
82
- )
83
- }
84
- } catch {
85
- throw new CliArgumentError('entrypointUnknown', { entrypoint })
86
- }
87
-
88
- if (!builderNames.includes(builder)) {
89
- throw new CliArgumentError('builderUnknown', { builder })
90
- }
91
-
92
- return args
93
- }