@cara/porter
Advanced tools
Comparing version 4.1.1 to 4.2.0
@@ -111,3 +111,3 @@ /* eslint-env browser */ | ||
requestStyle = function loadStyle(uri, callback) { | ||
if (typeof importScripts === 'function' || !rDigest.test(uri)) { | ||
if (typeof importScripts === 'function' || !rDigest.test(uri) || doc.querySelector('[href="' + uri + '"]')) { | ||
callback(); | ||
@@ -234,3 +234,3 @@ return; | ||
if (id.slice(-1) == '/') return id + 'index.js'; | ||
id = id.replace(/\.(?:js|jsx|ts|tsx|mjs|cjs)$/, '.js'); | ||
id = id.replace(/\.(?:jsx?|tsx?|mjs|cjs)$/, '.js').replace(/\.(?:less|sass|scss)$/, '.css'); | ||
return /\.(?:css|js|wasm)$/.test(id) ? id : id + '.js'; | ||
@@ -237,0 +237,0 @@ } |
{ | ||
"name": "@cara/porter", | ||
"description": "A middleware for web modules", | ||
"version": "4.1.1", | ||
"version": "4.2.0", | ||
"main": "src/porter.js", | ||
@@ -14,2 +14,4 @@ "repository": { | ||
"dependencies": { | ||
"@parcel/css": "^1.8.3", | ||
"browserslist": "^4.20.3", | ||
"debug": "^3.1.0", | ||
@@ -20,3 +22,3 @@ "glob": "^7.0.5", | ||
"mime": "^1.4.0", | ||
"postcss": "^8.2.10", | ||
"sass": "^1.51.0", | ||
"source-map": "^0.7.3", | ||
@@ -32,3 +34,2 @@ "uglify-js": "^3.14.3" | ||
"nyc": "^13.1.0", | ||
"postcss-preset-env": "^7.0.1", | ||
"semver": "^4.3.6", | ||
@@ -46,3 +47,3 @@ "sinon": "^12.0.1", | ||
"license": "BSD-3-Clause", | ||
"gitHead": "edc8ac54f9509afde9b2b39f186cb1d28aca5713" | ||
"gitHead": "6a764b1a1a5a796b247a4d93766483ac0a3752b1" | ||
} |
@@ -17,2 +17,4 @@ 'use strict'; | ||
const cssExtensions = [ '.css', '.less', '.sass', '.scss' ]; | ||
/** | ||
@@ -62,2 +64,8 @@ * @typedef { import("@babel/core").NodePath } NodePath | ||
}, | ||
ImportDeclaration(path) { | ||
const { node } = path; | ||
if (!cssExtensions.some(ext => node.source.value.endsWith(ext))) return; | ||
if (node.specifiers.length === 0) path.remove(); | ||
}, | ||
}; | ||
@@ -64,0 +72,0 @@ |
@@ -6,2 +6,3 @@ 'use strict'; | ||
const path = require('path'); | ||
const util = require('util'); | ||
const UglifyJS = require('uglify-js'); | ||
@@ -68,3 +69,3 @@ const { SourceMapConsumer, SourceMapGenerator, SourceNode } = require('source-map'); | ||
} | ||
results.push(cssBundle); | ||
results.unshift(cssBundle); | ||
} | ||
@@ -82,3 +83,3 @@ | ||
bundle.children.push(depBundle); | ||
results.push(depBundle); | ||
results.unshift(depBundle); | ||
} | ||
@@ -180,2 +181,4 @@ } | ||
} | ||
} else if (format === '.js' && entry.exports) { | ||
yield entry.exports; // css modules | ||
} | ||
@@ -337,3 +340,2 @@ if (mode === BREATH_FIRST) yield* iterate(entry, preload); | ||
this.#obtainCache = {}; | ||
await this.obtain(); | ||
} | ||
@@ -484,2 +486,63 @@ | ||
} | ||
/** | ||
* Fix source map related settings in both code and map. | ||
* @param {Object} result | ||
* @param {string} result.code | ||
* @param {Object|SourceMapGenerator} result.map | ||
* @param {Bundle} bundle | ||
* @param {string} bundle.outputPath | ||
*/ | ||
setSourceMap({ code, map }, bundle) { | ||
if (!map) return { code, map }; | ||
// normalize map | ||
if (map instanceof SourceMapGenerator) map = map.toJSON(); | ||
if (typeof map == 'string') map = JSON.parse(map); | ||
const { app } = this; | ||
if (app.source.inline !== true) { | ||
map.sourceRoot = app.source.root; | ||
map.sources = map.sources.map(source => source.replace(/^porter:\/\/\//, '')); | ||
map.sourcesContent = undefined; | ||
} | ||
const sourceMappingURL = app.source.mappingURL | ||
? `${app.source.mappingURL}${bundle.outputPath}.map` | ||
: `${path.basename(bundle.outputPath)}.map`; | ||
code = bundle.outputPath.endsWith('.js') | ||
? `${code}\n//# sourceMappingURL=${sourceMappingURL}` | ||
: `${code}\n/*# sourceMappingURL=${sourceMappingURL} */`; | ||
return { code, map }; | ||
} | ||
async compile(options = {}) { | ||
const { manifest = {}, writeFile = true } = options; | ||
if (await this.exists()) { | ||
const { entryPath, outputPath } = this; | ||
manifest[this.outkey] = this.output; | ||
debug('bundle exists %s -> %s', entryPath, outputPath, this.entries); | ||
return; | ||
} | ||
// compile dependencies first | ||
for (const child of this.children) await child.compile({ manifest }); | ||
const result = await this.minify(); | ||
const { app, outputPath } = this; | ||
if (!outputPath) { | ||
throw new Error(util.format('bundle empty %s %j', this.entryPath, this.entries)); | ||
} | ||
manifest[this.outkey] = this.output; | ||
const { code, map } = this.setSourceMap(result, this); | ||
if (!writeFile) return { code, map }; | ||
const fpath = path.join(app.output.path, outputPath); | ||
await fs.mkdir(path.dirname(fpath), { recursive: true }); | ||
await Promise.all([ | ||
fs.writeFile(fpath, code), | ||
map ? fs.writeFile(`${fpath}.map`, JSON.stringify(map)) : Promise.resolve(), | ||
]); | ||
} | ||
}; |
@@ -12,3 +12,3 @@ 'use strict'; | ||
'.wasm': [ '.wasm' ], | ||
'.css': [ '.css', '.less' ], | ||
'.css': [ '.css', '.less', '.scss', '.sass' ], | ||
}; | ||
@@ -15,0 +15,0 @@ |
@@ -5,4 +5,6 @@ 'use strict'; | ||
const path = require('path'); | ||
const css = require('@parcel/css'); | ||
const Module = require('./module'); | ||
const JsonModule = require('./json_module'); | ||
const { MODULE_LOADING, MODULE_LOADED } = require('./constants'); | ||
@@ -36,3 +38,3 @@ | ||
// ordering matters in css modules | ||
// precedence matters in css modules | ||
const result = await Promise.all(this.imports.map(this.parseImport, this)); | ||
@@ -49,27 +51,55 @@ this.children = result.filter(mod => mod != null); | ||
async transpile({ code, map }) { | ||
const { fpath, app } = this; | ||
const { cssTranspiler } = app; | ||
async transpile({ code, map, minify = false }) { | ||
const { file, fpath, packet, app } = this; | ||
if (!app.targets) app.targets = css.browserslistToTargets(app.browsers); | ||
/** | ||
* PostCSS doesn't support sourceRoot yet | ||
* https://github.com/postcss/postcss/blob/master/docs/source-maps.md | ||
*/ | ||
const result = await cssTranspiler.process(code, { | ||
from: fpath, | ||
path: this.app.paths, | ||
map: { | ||
// https://postcss.org/api/#sourcemapoptions | ||
inline: false, | ||
annotation: false, | ||
absolute: true, | ||
let result; | ||
try { | ||
result = css.transform({ | ||
filename: `porter:///${path.relative(app.root, fpath)}`, | ||
code: Buffer.from(code), | ||
minify, | ||
sourceMap: true, | ||
analyzeDependencies: true, | ||
cssModules: /\.module\.(?:css|scss|sass|less)$/.test(fpath), | ||
drafts: { | ||
nesting: true, | ||
customMedia: true, | ||
}, | ||
targets: app.targets, | ||
}); | ||
} catch (err) { | ||
const { data, source, loc } = err; | ||
let line = source.split('\n')[loc.line - 1]; | ||
let column = loc.column; | ||
if (line.length > 2058) { | ||
column = 128; | ||
line = `... ${line.slice(Math.max(0, loc.column - 128), Math.min(loc.column + 128, line.length))}`; | ||
} | ||
}); | ||
console.error(`${data.type}: ${data.value.type} (${path.relative(process.cwd(), fpath)}) | ||
map = JSON.parse(result.map); | ||
map.sources = map.sources.map(source => { | ||
return `porter:///${path.relative(app.root, source.replace(/^file:/, ''))}`; | ||
}); | ||
${line} | ||
${' '.repeat(column - 1)}↑`); | ||
return { code, map }; | ||
} | ||
return { code: result.css, map }; | ||
const { exports, dependencies = [] } = result; | ||
if (exports) { | ||
const mapping = {}; | ||
for (const key in exports) mapping[key] = exports[key].name; | ||
this.exports = new JsonModule({ file, fpath, packet, code: JSON.stringify(mapping) }); | ||
} | ||
let resultCode = result.code.toString(); | ||
for (const dep of dependencies) { | ||
if (dep.type === 'url') { | ||
resultCode = resultCode.replace(dep.placeholder, dep.url); | ||
} | ||
} | ||
return { | ||
code: resultCode, | ||
map: JSON.parse(result.map), | ||
}; | ||
} | ||
@@ -79,4 +109,4 @@ | ||
const { code, map } = await this.load(); | ||
return this.transpile({ code, map }); | ||
return this.transpile({ code, map, minify: true }); | ||
} | ||
}; |
@@ -144,8 +144,15 @@ 'use strict'; | ||
} | ||
// import './foo.d.ts'; | ||
for (const dep of imports) { | ||
if (!this.fake && !this.imports.includes(dep)) { | ||
const mod = await this.parseImport(dep); | ||
for (let i = this.children.length - 1; i >= 0; i--) { | ||
if (this.children[i] === mod) this.children.splice(i, 1); | ||
if (/\.(?:css|less|sass|scss)$/.test(dep)) { | ||
// import './baz.less'; | ||
this.imports.push(dep); | ||
} else { | ||
// import './foo.d.ts'; | ||
// import './bar.ts'; | ||
const mod = await this.parseImport(dep); | ||
for (let i = this.children.length - 1; i >= 0; i--) { | ||
if (this.children[i] === mod) this.children.splice(i, 1); | ||
} | ||
} | ||
@@ -152,0 +159,0 @@ } |
@@ -9,2 +9,7 @@ 'use strict'; | ||
module.exports = class JsonModule extends Module { | ||
constructor(options) { | ||
super(options); | ||
this.code = options.code; | ||
} | ||
async parse() { | ||
@@ -21,3 +26,3 @@ // nothing to parse here, just pure json data | ||
const { fpath } = this; | ||
const code = await readFile(fpath, 'utf8'); | ||
const code = this.code || await readFile(fpath, 'utf8'); | ||
return { code }; | ||
@@ -24,0 +29,0 @@ } |
@@ -23,12 +23,3 @@ 'use strict'; | ||
// async parseImport(dep) { | ||
// if (dep.startsWith('~')) return await super.parseImport(dep.slice(1)); | ||
// const mod = await this.parseRelative(dep); | ||
// if (mod) return mod; | ||
// return await super.parseImport(dep); | ||
// } | ||
async transpile({ code, map }) { | ||
async transpile({ code, map, minify }) { | ||
const { app, packet, fpath } = this; | ||
@@ -69,4 +60,4 @@ const less = app.packet.tryRequire('less'); | ||
}); | ||
return { code: result.css, map: result.map }; | ||
return super.transpile({ code: result.css, map: result.map, minify }); | ||
} | ||
}; |
@@ -9,6 +9,2 @@ 'use strict'; | ||
constructor({ file, fpath, packet }) { | ||
const { moduleCache } = packet.app; | ||
if (moduleCache[fpath]) return moduleCache[fpath]; | ||
moduleCache[fpath] = this; | ||
Object.defineProperties(this, { | ||
@@ -138,3 +134,5 @@ app: { | ||
const bundle = this.packet.bundles[this.file]; | ||
const { bundles, name, version } = this.packet; | ||
const bundle = bundles[this.file]; | ||
if (bundle && bundle.children?.length > 0) { | ||
@@ -149,3 +147,3 @@ for (const child of bundle.children) { | ||
// fake modules are self contained | ||
const copy = lock[this.packet.name][this.packet.version]; | ||
const copy = lock[name][version]; | ||
copy.manifest = undefined; | ||
@@ -152,0 +150,0 @@ } |
@@ -7,3 +7,2 @@ 'use strict'; | ||
const path = require('path'); | ||
const { SourceMapGenerator } = require('source-map'); | ||
const util = require('util'); | ||
@@ -19,2 +18,3 @@ | ||
const WasmModule = require('./wasm_module'); | ||
const SassModule = require('./sass_module'); | ||
const Stub = require('./stub'); | ||
@@ -24,2 +24,9 @@ const Bundle = require('./bundle'); | ||
function createModule(opts) { | ||
const { fpath, packet } = opts; | ||
const { moduleCache } = packet.app; | ||
if (moduleCache[fpath]) return moduleCache[fpath]; | ||
return (moduleCache[fpath] = Module.create(opts)); | ||
} | ||
/** | ||
@@ -49,2 +56,5 @@ * Leave the factory method of Module here to keep from cyclic dependencies. | ||
return new LessModule(opts); | ||
case '.sass': | ||
case '.scss': | ||
return new SassModule(opts); | ||
default: | ||
@@ -55,4 +65,2 @@ return new Stub(opts); | ||
const { lstat, readFile, realpath, writeFile } = fs; | ||
module.exports = class Packet { | ||
@@ -112,4 +120,4 @@ constructor({ app, dir, paths, parent, packet, alias } = {}) { | ||
// cnpm (npminstall) dedupes dependencies with symbolic links | ||
dir = await realpath(dir); | ||
const content = await readFile(path.join(dir, 'package.json'), 'utf8'); | ||
dir = await fs.realpath(dir); | ||
const content = await fs.readFile(path.join(dir, 'package.json'), 'utf8'); | ||
const data = JSON.parse(content); | ||
@@ -236,3 +244,3 @@ | ||
} else { | ||
const content = await readFile(configPath, 'utf8').catch(() => ''); | ||
const content = await fs.readFile(configPath, 'utf8').catch(() => ''); | ||
if (!content) continue; | ||
@@ -314,3 +322,3 @@ try { | ||
async reload(eventType, filename) { | ||
const { files, app, bundles } = this; | ||
const { files, app } = this; | ||
const mod = files[filename]; | ||
@@ -322,11 +330,18 @@ const { mtime } = await fs.stat(mod.fpath).catch(() => ({ mtime: null })); | ||
const { bundles: rootBundles } = app.packet; | ||
for (const bundle of Object.values(bundles).concat(Object.values(rootBundles))) { | ||
const bundles = Object.values(this.bundles); | ||
if (app.packet !== this) bundles.push(...Object.values(app.packet.bundles)); | ||
const outkeys = new Set(); | ||
for (const bundle of bundles) { | ||
for (const m of bundle) { | ||
if (m === mod) { | ||
await bundle.reload(); | ||
break; | ||
outkeys.add(bundle.outkey); | ||
if (bundle.format === '.js') outkeys.add(bundle.outkey.replace(/\.\w+$/, '.css')); | ||
} | ||
} | ||
} | ||
for (const bundle of bundles) { | ||
for (const outkey of outkeys) { | ||
if (bundle.outkey === outkey ) await bundle.reload(); | ||
} | ||
} | ||
} | ||
@@ -396,3 +411,3 @@ | ||
const mod = Module.create({ file, fpath, packet: this }); | ||
const mod = createModule({ file, fpath, packet: this }); | ||
return mod; | ||
@@ -443,3 +458,3 @@ } | ||
delete moduleCache[fpath]; | ||
const mod = Module.create({ file: entry, fpath, packet: this }); | ||
const mod = createModule({ file: entry, fpath, packet: this }); | ||
@@ -476,3 +491,3 @@ Object.assign(mod, { imports, code, fake: true }); | ||
const fpath = path.join(dir, `${file}${suffix}`); | ||
const stats = await lstat(fpath).catch(() => null); | ||
const stats = await fs.lstat(fpath).catch(() => null); | ||
if (stats && stats.isFile()) return [fpath, suffix]; | ||
@@ -557,3 +572,3 @@ } | ||
const fpath = path.join(__dirname, '..', 'loader.js'); | ||
const sourceContent = await readFile(fpath, 'utf8'); | ||
const sourceContent = await fs.readFile(fpath, 'utf8'); | ||
const code = await new Promise(resolve => { | ||
@@ -575,3 +590,3 @@ const stream = looseEnvify(fpath, { | ||
const entries = []; | ||
const { app, isolated, lazyloaded, main, bundles, files } = this; | ||
const { app, isolated, lazyloaded, main, files, bundles } = this; | ||
@@ -589,3 +604,3 @@ // the modules might not be fully parsed yet, the process returns early when parsing multiple times. | ||
for (const mod of Object.values(this.files)) { | ||
for (const mod of Object.values(files)) { | ||
if (mod.isRootEntry) { | ||
@@ -603,6 +618,9 @@ entries.push(mod.file); | ||
for (const entry of new Set(entries)) { | ||
const bundle = bundles[entry] || Bundle.create({ | ||
Bundle.create({ | ||
packet: this, | ||
entries: entry === main ? null : [ entry ], | ||
}); | ||
} | ||
for (const bundle of Object.values(bundles)) { | ||
if (bundle.entries.length > 0 && !(minify && await bundle.exists())) { | ||
@@ -614,60 +632,5 @@ await (minify ? bundle.minify() : bundle.obtain()); | ||
/** | ||
* Fix source map related settings in both code and map. | ||
* @param {Object} result | ||
* @param {string} result.code | ||
* @param {Object|SourceMapGenerator} result.map | ||
* @param {Bundle} bundle | ||
* @param {string} bundle.outputPath | ||
*/ | ||
setSourceMap({ code, map }, bundle) { | ||
if (!map) return { code, map }; | ||
// normalize map | ||
if (map instanceof SourceMapGenerator) map = map.toJSON(); | ||
if (typeof map == 'string') map = JSON.parse(map); | ||
const { source } = this.app; | ||
if (source.root) map.sourceRoot = source.root; | ||
const sourceMappingURL = source.mappingURL | ||
? `${source.mappingURL}${bundle.outputPath}.map` | ||
: `${path.basename(bundle.outputPath)}.map`; | ||
code = bundle.outputPath.endsWith('.js') | ||
? `${code}\n//# sourceMappingURL=${sourceMappingURL}` | ||
: `${code}\n/*# sourceMappingURL=${sourceMappingURL} */`; | ||
return { code, map }; | ||
} | ||
async writeSourceMap(fpath, map) { | ||
if (!map) return; | ||
const { app } = this; | ||
let resultMap; | ||
if (app.source.inline) { | ||
resultMap = JSON.stringify(map); | ||
} else { | ||
map.sources = map.sources.map(source => source.replace(/^porter:\/\/\//, '')); | ||
map.sourceRoot = app.source.root; | ||
resultMap = JSON.stringify(map, (k, v) => k !== 'sourcesContent' ? v : undefined); | ||
} | ||
await writeFile(`${fpath}.map`, resultMap); | ||
} | ||
async compileAll(opts) { | ||
const { entries, files, bundles, main } = this; | ||
for (const file in files) { | ||
if (file.endsWith('.wasm')) { | ||
bundles[file] = await this.compile(file, opts); | ||
} | ||
} | ||
for (const entry in entries) { | ||
if (entry.endsWith('.js') && entries[entry].isRootEntry) { | ||
bundles[entry] = await this.compile(entry, opts); | ||
} | ||
} | ||
bundles[main] = await this.compile([], opts); | ||
const { bundles } = this; | ||
for (const bundle of Object.values(bundles)) await bundle.compile(opts); | ||
} | ||
@@ -677,4 +640,4 @@ | ||
if (!Array.isArray(entries)) entries = [entries]; | ||
opts = { package: true, writeFile: true, ...opts }; | ||
const { manifest = {} } = opts; | ||
opts = { package: true, ...opts }; | ||
const { manifest = {}, writeFile = true } = opts; | ||
@@ -691,39 +654,14 @@ // compile({ entry: 'fake/entry', deps, code }, opts) | ||
const bundles = Bundle.wrap({ ...opts, packet: this, entries }); | ||
let result; | ||
for (const bundle of bundles) { | ||
result = await bundle.compile({ manifest, writeFile }); | ||
} | ||
for (let i = bundles.length - 1; i >= 0; i--) { | ||
const bundle = bundles[i]; | ||
if (await bundle.exists()) { | ||
const { entryPath, outputPath } = bundle; | ||
if (!this.parent) manifest[bundle.outkey] = bundle.output; | ||
debug('bundle exists %s -> %s', entryPath, outputPath, bundle.entries); | ||
continue; | ||
} | ||
const result = await bundle.minify(); | ||
const mod = this.files[entries[0]]; | ||
if (mod && mod.fake) { | ||
delete this.files[mod.file]; | ||
delete this.entries[mod.file]; | ||
delete app.moduleCache[mod.fpath]; | ||
} | ||
if (!this.parent) manifest[bundle.outkey] = bundle.output; | ||
const { code, map } = this.setSourceMap(result, bundle); | ||
if (!opts.writeFile) return { code, map }; | ||
const { outputPath } = bundle; | ||
if (!outputPath) { | ||
throw new Error(util.format('bundle empty %s %j', bundle.entryPath, bundle.entries)); | ||
} | ||
const fpath = path.join(app.output.path, outputPath); | ||
await fs.mkdir(path.dirname(fpath), { recursive: true }); | ||
await Promise.all([ | ||
writeFile(fpath, code), | ||
this.writeSourceMap(fpath, map), | ||
]); | ||
const mod = this.files[entries[0]]; | ||
if (mod && mod.fake) { | ||
delete this.files[mod.file]; | ||
delete this.entries[mod.file]; | ||
delete app.moduleCache[mod.fpath]; | ||
} | ||
return bundles[0]; | ||
return writeFile ? bundles[0] : result; | ||
} | ||
@@ -730,0 +668,0 @@ |
@@ -8,4 +8,4 @@ 'use strict'; | ||
const path = require('path'); | ||
const postcss = require('postcss'); | ||
const { SourceMapGenerator } = require('source-map'); | ||
const browserslist = require('browserslist'); | ||
@@ -20,3 +20,2 @@ const { lstat, readFile } = fs; | ||
const { MODULE_LOADED, rModuleId } = require('./constants'); | ||
const AtImport = require('./at_import'); | ||
const Cache = require('./cache'); | ||
@@ -114,5 +113,5 @@ const { EXTENSION_MAP } = require('./constants'); | ||
this.source = { serve: false, inline: false, root: 'http://localhost/', ...opts.source }; | ||
this.cssTranspiler = postcss([ AtImport ].concat(opts.postcssPlugins || [])); | ||
this.lessOptions = opts.lessOptions; | ||
this.uglifyOptions = opts.uglifyOptions; | ||
this.browsers = browserslist(); | ||
} | ||
@@ -146,3 +145,3 @@ | ||
async _pack({ minify = false } = {}) { | ||
async pack({ minify = false } = {}) { | ||
const { packet, entries, preload } = this; | ||
@@ -160,2 +159,6 @@ const files = preload.concat(entries); | ||
} | ||
for (const file of files) { | ||
Bundle.wrap({ packet, entries: [ file ] }); | ||
} | ||
} | ||
@@ -179,16 +182,5 @@ | ||
} | ||
await this._pack(); | ||
await this.pack({ minify: false }); | ||
} | ||
async pack({ minify = false } = {}) { | ||
await this._pack(); | ||
const { packet, entries, preload } = this; | ||
const files = preload.concat(entries); | ||
for (const file of files) { | ||
const [ bundle ] = Bundle.wrap({ packet, entries: [ file ] }); | ||
await (minify ? bundle.minify() : bundle.obtain()); | ||
} | ||
} | ||
prepareFiles(files, isEntry = false) { | ||
@@ -244,3 +236,6 @@ const { packet } = this; | ||
// compileAll(entries) needs to defer packing, otherwise pack when ready | ||
if (!minify) await this.pack({ minify }); | ||
if (!minify) { | ||
await this.pack({ minify }); | ||
for (const bundle of Object.values(packet.bundles)) await bundle.obtain(); | ||
} | ||
} | ||
@@ -282,3 +277,3 @@ | ||
debug('packing necessary bundles'); | ||
await this._pack({ minify: true }); | ||
await this.pack({ minify: true }); | ||
@@ -292,8 +287,3 @@ debug('compile packets'); | ||
debug('compile preload'); | ||
const manifest = {}; | ||
for (const file of this.preload) { | ||
await this.packet.compile(file, { all: this.preload.length > 0, manifest }); | ||
} | ||
debug('compile lazyload'); | ||
@@ -306,5 +296,5 @@ for (const mod of this.lazyloads) { | ||
debug('compile entries'); | ||
for (const entry of entries) { | ||
await this.packet.compile(entry, { all: this.preload.length > 0, manifest }); | ||
debug('compile preload and entries'); | ||
for (const bundle of Object.values(this.packet.bundles)) { | ||
await bundle.compile({ manifest }); | ||
} | ||
@@ -387,3 +377,6 @@ | ||
await this.reload(); | ||
if (mod) [ bundle ] = Bundle.wrap({ packet, entries: [ mod.file ], format, loader }); | ||
if (mod) { | ||
const bundles = Bundle.wrap({ packet, entries: [ mod.file ], format, loader }); | ||
bundle = bundles[bundles.length - 1]; | ||
} | ||
} | ||
@@ -390,0 +383,0 @@ |
125750
9
3387
10
+ Added@parcel/css@^1.8.3
+ Addedbrowserslist@^4.20.3
+ Addedsass@^1.51.0
+ Added@parcel/css@1.14.0(transitive)
+ Added@parcel/watcher@2.5.1(transitive)
+ Added@parcel/watcher-android-arm64@2.5.1(transitive)
+ Added@parcel/watcher-darwin-arm64@2.5.1(transitive)
+ Added@parcel/watcher-darwin-x64@2.5.1(transitive)
+ Added@parcel/watcher-freebsd-x64@2.5.1(transitive)
+ Added@parcel/watcher-linux-arm-glibc@2.5.1(transitive)
+ Added@parcel/watcher-linux-arm-musl@2.5.1(transitive)
+ Added@parcel/watcher-linux-arm64-glibc@2.5.1(transitive)
+ Added@parcel/watcher-linux-arm64-musl@2.5.1(transitive)
+ Added@parcel/watcher-linux-x64-glibc@2.5.1(transitive)
+ Added@parcel/watcher-linux-x64-musl@2.5.1(transitive)
+ Added@parcel/watcher-win32-arm64@2.5.1(transitive)
+ Added@parcel/watcher-win32-ia32@2.5.1(transitive)
+ Added@parcel/watcher-win32-x64@2.5.1(transitive)
+ Addedbraces@3.0.3(transitive)
+ Addedbrowserslist@4.24.4(transitive)
+ Addedcaniuse-lite@1.0.30001700(transitive)
+ Addedchokidar@4.0.3(transitive)
+ Addeddetect-libc@1.0.3(transitive)
+ Addedelectron-to-chromium@1.5.102(transitive)
+ Addedescalade@3.2.0(transitive)
+ Addedfill-range@7.1.1(transitive)
+ Addedimmutable@5.0.3(transitive)
+ Addedis-extglob@2.1.1(transitive)
+ Addedis-glob@4.0.3(transitive)
+ Addedis-number@7.0.0(transitive)
+ Addedlightningcss@1.29.1(transitive)
+ Addedlightningcss-darwin-arm64@1.29.1(transitive)
+ Addedlightningcss-darwin-x64@1.29.1(transitive)
+ Addedlightningcss-freebsd-x64@1.29.1(transitive)
+ Addedlightningcss-linux-arm-gnueabihf@1.29.1(transitive)
+ Addedlightningcss-linux-arm64-gnu@1.29.1(transitive)
+ Addedlightningcss-linux-arm64-musl@1.29.1(transitive)
+ Addedlightningcss-linux-x64-gnu@1.29.1(transitive)
+ Addedlightningcss-linux-x64-musl@1.29.1(transitive)
+ Addedlightningcss-win32-arm64-msvc@1.29.1(transitive)
+ Addedlightningcss-win32-x64-msvc@1.29.1(transitive)
+ Addedmicromatch@4.0.8(transitive)
+ Addednode-addon-api@7.1.1(transitive)
+ Addednode-releases@2.0.19(transitive)
+ Addedpicomatch@2.3.1(transitive)
+ Addedreaddirp@4.1.2(transitive)
+ Addedsass@1.85.0(transitive)
+ Addedto-regex-range@5.0.1(transitive)
+ Addedupdate-browserslist-db@1.1.2(transitive)
- Removedpostcss@^8.2.10
- Removednanoid@3.3.8(transitive)
- Removedpostcss@8.5.3(transitive)