-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Ejected chomp templates to better thread NODE_ENV param through the b…
- Loading branch information
Showing
4 changed files
with
81 additions
and
39 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,25 +1,25 @@ | ||
version = 0.1 | ||
default-task = 'start' | ||
extensions = ['[email protected]:jspm', '[email protected]:swc'] | ||
|
||
############################# | ||
############################# | ||
############################# | ||
|
||
[[task]] | ||
name = 'start' | ||
deps = [ | ||
'.cache', | ||
'.cache/*.html', | ||
'copy-static-files', | ||
'server', | ||
] | ||
serial = true | ||
deps = ['.cache', '.cache/*.html', 'copy-static-files', 'server'] | ||
|
||
############################# | ||
############################# | ||
############################# | ||
|
||
[[task]] | ||
name = 'copy-static-files' | ||
run = """ | ||
run = ''' | ||
cp -r public/* .cache/ | ||
""" | ||
''' | ||
|
||
[[task]] | ||
name = 'server' | ||
|
@@ -58,36 +58,31 @@ run = 'rollup -c rollup/server.config.js' | |
# Create an import map for node | ||
[[task]] | ||
name = 'jspm:node' | ||
deps = ['index.importmap.js', '.cache'] | ||
target = 'node.importmap' | ||
template = 'jspm' | ||
[task.template-options] | ||
default-provider = 'jspm' | ||
env = ['node', 'production', 'module'] | ||
ignore = [ | ||
'mongodb', | ||
'graphql', | ||
'apollo-server-core', | ||
'apollo-server-koa', | ||
'koa-bodyparser', | ||
'http-errors' | ||
targets = ['node.importmap'] | ||
deps = [ | ||
'index.importmap.js', | ||
'.cache' | ||
] | ||
invalidation = 'always' | ||
run = "node jspm-node.js" | ||
|
||
# Transpile HTML + js => HTML / import map | ||
[[task]] | ||
name = 'jspm:client' | ||
deps = ['client/html/#.html', '.cache'] | ||
target = '.cache/#.html' | ||
template = 'jspm' | ||
[task.template-options] | ||
env = ['browser', 'production', 'module'] | ||
default-provider = 'jspm' | ||
preload = false | ||
integrity = false | ||
targets = ['.cache/#.html'] | ||
deps = [ | ||
'client/html/#.html', | ||
'.cache' | ||
] | ||
invalidation = 'always' | ||
run = "node jspm-client.js" | ||
|
||
[[task]] | ||
target = '.cache' | ||
deps = ['client/**/*', 'common/**/*'] | ||
deps = [ | ||
'client/**/*', | ||
'common/**/*' | ||
] | ||
env = { TZ='UTC'} | ||
run = """ | ||
prettier \ | ||
|
@@ -101,19 +96,19 @@ prettier \ | |
--config rollup/client.config.js | ||
""" | ||
|
||
# First delete and recreate the cache | ||
[[task]] | ||
name = 'clear-cache' | ||
run = """ | ||
run = ''' | ||
rimraf node.importmap | ||
rimraf .cache | ||
rimraf .ssr | ||
""" | ||
''' | ||
|
||
############################# | ||
############################# | ||
############################# | ||
|
||
|
||
[[task]] | ||
name = 'prettier' | ||
run = """ | ||
|
@@ -129,8 +124,6 @@ prettier \ | |
--write "./*.@(js|jsx|json|mjs|cjs|graphql|yml|ts|tsx)" | ||
""" | ||
|
||
# DEPENDENCY MANAGEMNT | ||
|
||
[[task]] | ||
name = 'reset' | ||
run = 'find . -name node_modules -type d -exec rm -rv {} + && find . -name package-lock.json -type f -delete' | ||
|
@@ -141,8 +134,7 @@ run = 'ncu' | |
|
||
[[task]] | ||
name = 'ncu:u' | ||
run = """ | ||
run = ''' | ||
ncu -u | ||
npm install | ||
""" | ||
|
||
''' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
import { Generator } from '@jspm/generator' | ||
import { readFile, writeFile } from 'fs/promises' | ||
import { pathToFileURL } from 'url' | ||
import mkdirp from 'mkdirp' | ||
import { dirname } from 'path' | ||
|
||
const NODE_ENV = process.env.NODE_ENV || 'development' | ||
|
||
const generator = new Generator({ | ||
mapUrl: pathToFileURL(process.env.TARGET), | ||
env: ['browser', NODE_ENV, 'module'], | ||
defaultProvider: 'jspm', | ||
}) | ||
|
||
const htmlSource = await readFile(process.env.DEP, 'utf-8') | ||
|
||
mkdirp.sync(dirname(process.env.TARGET)) | ||
await writeFile( | ||
process.env.TARGET, | ||
await generator.htmlGenerate(htmlSource, { | ||
htmlUrl: pathToFileURL(process.env.TARGET), | ||
preload: false, | ||
integrity: false, | ||
}) | ||
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
import { Generator } from '@jspm/generator' | ||
import { writeFile } from 'fs/promises' | ||
import mkdirp from 'mkdirp' | ||
import { dirname } from 'path' | ||
|
||
const NODE_ENV = process.env.NODE_ENV || 'development' | ||
|
||
const generator = new Generator({ | ||
mapUrl: import.meta.url, | ||
env: ['node', NODE_ENV, 'module'], | ||
defaultProvider: 'jspm', | ||
ignore: [ | ||
'mongodb', | ||
'graphql', | ||
'apollo-server-core', | ||
'apollo-server-koa', | ||
'koa-bodyparser', | ||
'http-errors', | ||
], | ||
}) | ||
|
||
await Promise.all(process.env.DEPS.split(':').map(dep => generator.traceInstall('./' + dep))) | ||
|
||
mkdirp.sync(dirname(process.env.TARGET)) | ||
await writeFile(process.env.TARGET, JSON.stringify(generator.getMap(), null, 2)) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters