-
Notifications
You must be signed in to change notification settings - Fork 35
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
🐈🐈🐈 #657
The head ref may contain hidden characters: "\u{1F408}.json"
🐈🐈🐈 #657
Changes from all commits
876d932
9ef1a4b
2fda1f7
9c68c69
7517e14
02df0ea
4665c87
6a980b2
efb2e06
330cb36
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
This file was deleted.
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,123 @@ | ||
"civet coffeeCompat" | ||
|
||
esbuild = require "esbuild" | ||
heraPlugin = require "@danielx/hera/esbuild-plugin" | ||
# Need to use the packaged version because we may not have built our own yet | ||
civetPlugin = require "../node_modules/@danielx/civet/dist/esbuild-plugin.js" | ||
|
||
watch = process.argv.includes '--watch' | ||
minify = false | ||
sourcemap = false | ||
|
||
path = require "path" | ||
{access} = require "fs/promises" | ||
exists = (p) -> | ||
access(p) | ||
.then -> | ||
true | ||
.catch -> | ||
false | ||
extensionResolverPlugin = (extensions) -> | ||
name: "extension-resolve" | ||
setup: (build) -> | ||
# For relative requires that don't contain a '.' | ||
build.onResolve { filter: /\/[^.]*$/ }, (r) -> | ||
for extension in extensions | ||
{path: resolvePath, resolveDir} = r | ||
p = path.join(resolveDir, resolvePath + ".#{extension}") | ||
|
||
# see if a .coffee file exists | ||
found = await exists(p) | ||
if found | ||
return path: p | ||
|
||
return undefined | ||
|
||
resolveExtensions = extensionResolverPlugin(["civet", "hera"]) | ||
|
||
# To get proper extension resolution for non-bundled files, we need to use | ||
# a plugin hack: https://github.com/evanw/esbuild/issues/622#issuecomment-769462611 | ||
# set bundle: true, then rewrite .coffee -> .js and mark as external | ||
# Also marking everything else as external since we don't want to bundle anything | ||
rewriteCivetImports = { | ||
name: 'rewrite-civet', | ||
setup: (build) -> | ||
build.onResolve { filter: /.*/ }, (args) -> | ||
if (args.importer) | ||
path: args.path.replace(/\.civet$/, ".js") | ||
external: true | ||
} | ||
|
||
# Files that need civet imports re-written | ||
# since they aren't actually bundled | ||
["cli", "config", "esbuild-plugin"].forEach (name) -> | ||
esbuild.build({ | ||
entryPoints: ["source/#{name}.civet"] | ||
bundle: true | ||
platform: 'node' | ||
format: 'cjs' | ||
outfile: "dist/#{name}.js" | ||
plugins: [ | ||
rewriteCivetImports | ||
civetPlugin() | ||
] | ||
}).catch -> process.exit 1 | ||
|
||
# esm needs to be a module for import.meta | ||
["esm"].forEach (name) -> | ||
esbuild.build({ | ||
entryPoints: ["source/#{name}.civet"] | ||
bundle: true | ||
platform: 'node' | ||
format: 'esm' | ||
outfile: "dist/#{name}.mjs" | ||
plugins: [ | ||
rewriteCivetImports | ||
civetPlugin() | ||
] | ||
}).catch -> process.exit 1 | ||
|
||
for esm in [false, true] | ||
esbuild.build({ | ||
entryPoints: ['source/main.civet'] | ||
bundle: true | ||
watch | ||
platform: 'node' | ||
format: if esm then 'esm' else 'cjs' | ||
outfile: "dist/main.#{if esm then 'mjs' else 'js'}" | ||
plugins: [ | ||
resolveExtensions | ||
civetPlugin() | ||
heraPlugin | ||
] | ||
}).catch -> process.exit 1 | ||
|
||
esbuild.build({ | ||
entryPoints: ['source/main.civet'] | ||
globalName: "Civet" | ||
bundle: true | ||
sourcemap | ||
watch | ||
platform: 'browser' | ||
outfile: 'dist/browser.js' | ||
plugins: [ | ||
resolveExtensions | ||
civetPlugin() | ||
heraPlugin | ||
] | ||
}).catch -> process.exit 1 | ||
|
||
esbuild.build({ | ||
entryPoints: ['source/bun-civet.civet'] | ||
bundle: false | ||
sourcemap | ||
minify | ||
watch | ||
platform: 'node' | ||
format: 'esm' | ||
target: "esNext" | ||
outfile: 'dist/bun-civet.mjs' | ||
plugins: [ | ||
civetPlugin() | ||
] | ||
}).catch -> process.exit 1 |
This file was deleted.
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -14,7 +14,6 @@ | |
"./esm": "./dist/esm.mjs", | ||
"./esbuild-plugin": "./dist/esbuild-plugin.js", | ||
"./register": "./register.js", | ||
"./config": "./dist/config.js", | ||
"./*": "./*", | ||
"./dist/*": "./dist/*" | ||
}, | ||
|
@@ -43,15 +42,14 @@ | |
"@cspotcode/source-map-support": "^0.8.1" | ||
}, | ||
"devDependencies": { | ||
"@danielx/civet": "^0.6.26", | ||
"@danielx/hera": "^0.8.10", | ||
"@types/assert": "^1.5.6", | ||
"@types/coffeescript": "^2.5.2", | ||
"@types/mocha": "^9.1.1", | ||
"@types/node": "^18.7.8", | ||
"axios": "^1.2.2", | ||
"c8": "^7.12.0", | ||
"esbuild": "^0.14.49", | ||
"esbuild-coffeescript": "^2.1.0", | ||
"marked": "^4.2.4", | ||
"mocha": "^10.0.0", | ||
"prettier": "^2.8.1", | ||
|
@@ -71,7 +69,10 @@ | |
"extension": [ | ||
".civet", | ||
".coffee", | ||
".hera", | ||
".js", | ||
".mjs", | ||
".mts", | ||
".ts" | ||
], | ||
"include": [ | ||
|
@@ -85,9 +86,8 @@ | |
], | ||
"loader": [ | ||
"ts-node/esm", | ||
"./build/coffee-esm.mjs", | ||
"./build/hera-esm.mjs", | ||
"./dist/esm.mjs" | ||
"./node_modules/@danielx/civet/dist/esm.mjs" | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Will this use the correct version of Civet? We need tests to run in the repo version, not in the released version. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This is the version that will parse the source and test files. Once parsed the tests are run against There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Ah, got it. (If only we could add a comment to a JSON file. 😉) That seems fine, because we don't generally use fancy features in the test infrastructure, only inside the triple quotes. Actually, in some ways, it will be an improvement; I've run into issues where I break the Civet compiler (and ran |
||
], | ||
"reporter": "dot", | ||
"recursive": true, | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'd feel safer if this were a pinned dep (no
^
). Given how we tend to change things and just bump the patch number. 😅There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I believe the lockfile should take care of it but being explicit here would also be fine.