Comparing version 0.6.1 to 0.6.2
@@ -79,3 +79,3 @@ var Module = require('module') | ||
quibble.esm = async function (importPath, namedExportStubs, defaultExportStub) { | ||
if (!global.__quibble) { global.__quibble = { quibbledModules: new Map(), stubModuleGeneration: 1 } } | ||
checkThatLoaderIsLoaded() | ||
@@ -104,3 +104,9 @@ if (!global.__quibble.quibbledModules) { | ||
quibble.isLoaderLoaded = function () { | ||
return !!global.__quibble | ||
} | ||
quibble.esmImportWithPath = async function esmImportWithPath (importPath) { | ||
checkThatLoaderIsLoaded() | ||
const importPathIsBareSpecifier = isBareSpecifier(importPath) | ||
@@ -228,2 +234,8 @@ const isAbsolutePath = path.isAbsolute(importPath) | ||
function checkThatLoaderIsLoaded () { | ||
if (!global.__quibble) { | ||
throw new Error('quibble loader not loaded. You cannot replace ES modules without a loader. Run node with `--loader=quibble`.') | ||
} | ||
} | ||
function convertUrlToPath (fileUrl) { | ||
@@ -230,0 +242,0 @@ try { |
{ | ||
"name": "quibble", | ||
"version": "0.6.1", | ||
"version": "0.6.2", | ||
"description": "Makes it easy to replace require'd dependencies.", | ||
@@ -18,6 +18,7 @@ "homepage": "https://github.com/testdouble/quibble", | ||
"test:esm": "if node test/supports-esm.js; then NODE_OPTIONS=--loader=quibble ./test/esm-lib/teenytest-proxy.js './test/esm-lib/*.test.{mjs,js}'; fi", | ||
"test:no-loader-esm": "if node test/supports-esm.js; then teenytest './test/esm-lib/*.no-loader-test.{mjs,js}'; fi", | ||
"test:example": "cd example && npm it", | ||
"test:example-esm": "if node test/supports-esm.js; then node test/supports-esm.js && cd example && npm it; fi", | ||
"test:smells": "./test/require-smell-test.sh", | ||
"test:ci": "npm test && npm run test:esm && npm run style && npm run test:example && npm run test:example-esm && npm run test:smells", | ||
"test:ci": "npm test && npm run test:esm && npm run test:no-loader-esm && npm run style && npm run test:example && npm run test:example-esm && npm run test:smells", | ||
"preversion": "git pull --rebase && npm run test:ci", | ||
@@ -24,0 +25,0 @@ "postversion": "git push && git push --tags && npm publish" |
@@ -94,3 +94,6 @@ const quibble = require('quibble') | ||
}) | ||
}, | ||
'isLoaderLoader returns true if loader as loaded': async function () { | ||
assert.equal(quibble.isLoaderLoaded(), true) | ||
} | ||
} |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
205369
45
4746