@@ -80,7 +80,6 @@ function greenwoodWorkspaceResolver (compilation) {
80
80
return {
81
81
name : 'greenwood-workspace-resolver' ,
82
82
resolveId ( source ) {
83
- // TODO better way to handle relative paths? happens in generateBundle too
84
83
if ( ( source . indexOf ( './' ) === 0 || source . indexOf ( '/' ) === 0 ) && path . extname ( source ) !== '.html' && fs . existsSync ( path . join ( userWorkspace , source ) ) ) {
85
84
return source . replace ( source , path . join ( userWorkspace , source ) ) ;
86
85
}
@@ -126,7 +125,6 @@ function greenwoodHtmlPlugin(compilation) {
126
125
: null ;
127
126
} ) ) ) . filter ( resource => resource ) ;
128
127
129
- // TODO should reduce here instead
130
128
if ( resourceHandler . length ) {
131
129
const response = await resourceHandler [ 0 ] . serve ( id ) ;
132
130
@@ -153,8 +151,7 @@ function greenwoodHtmlPlugin(compilation) {
153
151
} ) ;
154
152
const headScripts = root . querySelectorAll ( 'script' ) ;
155
153
const headLinks = root . querySelectorAll ( 'link' ) ;
156
-
157
- // TODO handle deeper paths. e.g. ../../../
154
+
158
155
headScripts . forEach ( ( scriptTag ) => {
159
156
const parsedAttributes = parseTagForAttributes ( scriptTag ) ;
160
157
@@ -165,9 +162,6 @@ function greenwoodHtmlPlugin(compilation) {
165
162
} else {
166
163
const { src } = parsedAttributes ;
167
164
168
- // TODO avoid using href and set it to the value of rollup fileName instead
169
- // since user paths can still be the same file,
170
- // e.g. ../theme.css and ./theme.css are still the same file
171
165
mappedScripts . set ( src , true ) ;
172
166
173
167
const srcPath = src . replace ( '../' , './' ) ;
@@ -196,12 +190,7 @@ function greenwoodHtmlPlugin(compilation) {
196
190
${ scriptTag . rawText }
197
191
` . trim ( ) ;
198
192
199
- // have to write a file for rollup?
200
193
fs . writeFileSync ( path . join ( scratchDir , filename ) , source ) ;
201
-
202
- // TODO avoid using href and set it to the value of rollup fileName instead
203
- // since user paths can still be the same file,
204
- // e.g. ../theme.css and ./theme.css are still the same file
205
194
mappedScripts . set ( id , true ) ;
206
195
207
196
this . emitFile ( {
@@ -225,7 +214,6 @@ function greenwoodHtmlPlugin(compilation) {
225
214
href = href . slice ( 1 ) ;
226
215
}
227
216
228
- // TODO handle auto expanding deeper paths
229
217
const basePath = href . indexOf ( tokenNodeModules ) >= 0
230
218
? projectDirectory
231
219
: userWorkspace ;
@@ -244,9 +232,6 @@ function greenwoodHtmlPlugin(compilation) {
244
232
} ) ;
245
233
}
246
234
247
- // TODO avoid using href and set it to the value of rollup fileName instead
248
- // since user paths can still be the same file,
249
- // e.g. ../theme.css and ./theme.css are still the same file
250
235
mappedStyles [ parsedAttributes . href ] = {
251
236
type : 'asset' ,
252
237
fileName : fileName . indexOf ( tokenNodeModules ) >= 0
@@ -298,7 +283,6 @@ function greenwoodHtmlPlugin(compilation) {
298
283
try {
299
284
const bundle = bundles [ bundleId ] ;
300
285
301
- // TODO handle (!) Generated empty chunks .greenwood/about, .greenwood/index
302
286
if ( bundle . isEntry && path . extname ( bundle . facadeModuleId ) === '.html' ) {
303
287
const html = fs . readFileSync ( bundle . facadeModuleId , 'utf-8' ) ;
304
288
const root = htmlparser . parse ( html , {
@@ -373,7 +357,6 @@ function greenwoodHtmlPlugin(compilation) {
373
357
}
374
358
} ) ;
375
359
376
- // TODO this seems hacky; hardcoded dirs :D
377
360
bundle . fileName = bundle . facadeModuleId . replace ( '.greenwood' , 'public' ) ;
378
361
bundle . code = newHtml ;
379
362
}
@@ -390,7 +373,6 @@ function greenwoodHtmlPlugin(compilation) {
390
373
const bundle = bundles [ bundleId ] ;
391
374
392
375
if ( bundle . isEntry && path . extname ( bundle . facadeModuleId ) === '.html' ) {
393
- // TODO this seems hacky; hardcoded dirs :D
394
376
const htmlPath = bundle . facadeModuleId . replace ( '.greenwood' , 'public' ) ;
395
377
let html = fs . readFileSync ( htmlPath , 'utf-8' ) ;
396
378
const root = htmlparser . parse ( html , {
@@ -478,17 +460,15 @@ function greenwoodHtmlPlugin(compilation) {
478
460
module . exports = getRollupConfig = async ( compilation ) => {
479
461
const { scratchDir, outputDir } = compilation . context ;
480
462
const defaultRollupPlugins = [
481
- // TODO replace should come in via plugin-node-modules
482
463
replace ( { // https://github.com/rollup/rollup/issues/487#issuecomment-177596512
483
464
'process.env.NODE_ENV' : JSON . stringify ( 'production' )
484
465
} ) ,
485
- nodeResolve ( ) , // TODO move to plugin-node-modules
466
+ nodeResolve ( ) ,
486
467
greenwoodWorkspaceResolver ( compilation ) ,
487
468
greenwoodHtmlPlugin ( compilation ) ,
488
469
multiInput ( ) ,
489
- json ( ) // TODO make it part plugin-standard-json
470
+ json ( )
490
471
] ;
491
- // TODO greenwood standard plugins, then "Greenwood" plugins, then user plugins
492
472
const customRollupPlugins = compilation . config . plugins . filter ( ( plugin ) => {
493
473
return plugin . type === 'rollup' ;
494
474
} ) . map ( ( plugin ) => {
@@ -497,12 +477,11 @@ module.exports = getRollupConfig = async (compilation) => {
497
477
498
478
if ( compilation . config . optimization !== 'none' ) {
499
479
defaultRollupPlugins . push (
500
- terser ( ) // TODO extract to plugin-standard-javascript
480
+ terser ( )
501
481
) ;
502
482
}
503
483
504
484
return [ {
505
- // TODO Avoid .greenwood/ directory, do everything in public/?
506
485
input : `${ scratchDir } **/*.html` ,
507
486
output : {
508
487
dir : outputDir ,
0 commit comments