@cara/porter
Advanced tools
Comparing version 3.1.4-3.2.0-alpha.0.0 to 3.1.4
@@ -232,3 +232,2 @@ /* eslint-env browser */ | ||
this.status = MODULE_INIT | ||
this.meta = { url: baseUrl + id } | ||
registry[id] = this | ||
@@ -278,2 +277,3 @@ } | ||
mod.ignite() | ||
fetching[uri] = null | ||
}) | ||
@@ -363,5 +363,4 @@ } | ||
// function(require, exports, module, __module) {} | ||
var exports = typeof factory === 'function' | ||
? factory.call(null, require, mod.exports, mod, mod) | ||
? factory.call(null, require, mod.exports, mod) | ||
: factory | ||
@@ -368,0 +367,0 @@ |
{ | ||
"name": "@cara/porter", | ||
"description": "A koa and express middleware for browser side javascript module authoring.", | ||
"version": "3.1.4-3.2.0-alpha.0.0", | ||
"version": "3.1.4", | ||
"main": "src/porter.js", | ||
@@ -6,0 +6,0 @@ "repository": { |
@@ -101,3 +101,3 @@ 'use strict' | ||
code: [ | ||
`define(${JSON.stringify(id)}, ${JSON.stringify(deps)}, function(require, exports, module, __module) {${code}`, | ||
`define(${JSON.stringify(id)}, ${JSON.stringify(deps)}, function(require, exports, module) {${code}`, | ||
'})' | ||
@@ -104,0 +104,0 @@ ].join('\n'), |
@@ -19,3 +19,2 @@ 'use strict' | ||
const JsonModule = require('./jsonModule') | ||
const WasmModule = require('./wasmModule') | ||
@@ -33,4 +32,2 @@ /** | ||
return new JsonModule(opts) | ||
case '.wasm': | ||
return new WasmModule(opts) | ||
default: | ||
@@ -73,4 +70,3 @@ return new JsModule(opts) | ||
// should prefer pkg.module but since we don't have tree shaking yet... | ||
const main = typeof pkg.browser == 'string' ? pkg.browser : (pkg.main || pkg.module) | ||
const main = typeof pkg.browser == 'string' ? pkg.browser : pkg.main | ||
this.main = main ? main.replace(/^\.\//, '') : 'index.js' | ||
@@ -283,14 +279,5 @@ | ||
// "browser" mapping in package.json | ||
file = (browser[`./${file}`] || browser[`./${file}.js`] || file).replace(/^[\.\/]+/, '') | ||
// explicit directory require | ||
if (file.endsWith('/')) file += 'index.js' | ||
// extension duduction | ||
if (!['.css', '.js', '.json', '.wasm'].includes(path.extname(file))) { | ||
file += '.js' | ||
} | ||
// if parsed already | ||
if (!['.css', '.js', '.json'].includes(path.extname(file))) file += '.js' | ||
if (file in files) return files[file] | ||
@@ -301,4 +288,4 @@ | ||
if (fpath) { | ||
const realpath = (await glob(fpath, { nocase: true, cwd: this.dir}))[0] | ||
if (fpath !== realpath) throw new Error(`case mismatch ${file} (${realpath})`) | ||
const fPath = (await glob(fpath, { nocase: true, cwd: this.dir}))[0] | ||
if (fpath !== fPath) throw new Error(`case mismatch ${file} (${fPath})`) | ||
if (suffix.includes('/index')) { | ||
@@ -317,3 +304,3 @@ file = file.replace(/\.\w+$/, suffix) | ||
// entry is '' when `require('foo/')`, should fallback to `this.main` | ||
if (!entry) entry = this.module || this.main | ||
if (!entry) entry = this.main | ||
const { app, dir, entries, name, version, files } = this | ||
@@ -551,3 +538,2 @@ const mod = await this.parseModule(entry) | ||
if (mod.package !== pkg && mod.package.isolated && !ancestor.isPreload) return | ||
if (mod.isolated) return | ||
@@ -554,0 +540,0 @@ done[mod.id] = true |
@@ -327,21 +327,2 @@ 'use strict' | ||
async readWasm(id) { | ||
let [, name, version, file] = id.match(rModuleId) | ||
let pkg | ||
if (!version) { | ||
pkg = this.package | ||
name = pkg.name | ||
version = pkg.version | ||
file = id | ||
} else { | ||
pkg = this.package.find({ name, version }) | ||
} | ||
const mod = await pkg.parseFile(file) | ||
const { code } = await mod.obtain() | ||
const mtime = (await lstat(mod.fpath)).mtime.toJSON() | ||
return [code, { 'Last-Modified': mtime }] | ||
} | ||
async readFile(file, query) { | ||
@@ -378,5 +359,2 @@ await this.ready | ||
} | ||
else if (ext === '.wasm') { | ||
result = await this.readWasm(file) | ||
} | ||
else if (rExt.test(ext)) { | ||
@@ -383,0 +361,0 @@ const [fpath] = await pkg.resolve(file) |
No v1
QualityPackage is not semver >=1. This means it is not stable and does not support ^ ranges.
Found 1 instance in 1 package
1
85735
13
2169