diff --git a/src/Route.svelte b/src/Route.svelte
index 2fbf943f..e96a6cad 100644
--- a/src/Route.svelte
+++ b/src/Route.svelte
@@ -1,8 +1,8 @@
diff --git a/src/rollup-plugin-filerouter.js b/src/rollup-plugin-filerouter.js
index 884c1e58..288b26cf 100644
--- a/src/rollup-plugin-filerouter.js
+++ b/src/rollup-plugin-filerouter.js
@@ -11,7 +11,7 @@ module.exports = function fileRouter(options = {}) {
ignore: [],
unknownPropWarnings: true
}, options)
-
+
return {
name: 'file-router',
@@ -29,12 +29,9 @@ module.exports = function fileRouter(options = {}) {
}
}
-async function createGeneratedRoutes(options){
+async function createGeneratedRoutes(options) {
+ clientOptions = { unknownPropWarnings: options.unknownPropWarnings }
let str = await filesToRoutes(options)
-
- if(!options.unknownPropWarnings){
- str += `\n\n const suppressWarnings = ${scripts.suppressWarnings.toString()}`
- str += `\n suppressWarnings()`
- }
+ str += `\n\n export const options = ${JSON.stringify(clientOptions)}`
return str
}
\ No newline at end of file
diff --git a/src/scripts.js b/src/scripts.js
index fa0708ff..38497e32 100644
--- a/src/scripts.js
+++ b/src/scripts.js
@@ -1,13 +1,32 @@
-
-module.exports.suppressWarnings = function () {
+module.exports.suppressWarnings = (function () {
+ const _ignoreList = []
+ let initialized = false
const _warn = console.warn
- console.warn = function (...params) {
- const msg = params[0]
- const ignores = ['scoped', 'route', 'routes', 'url']
- const match = ignores.filter(prop => msg.match(new RegExp(`was created with unknown prop '${prop}'`))).length
- if (!match)
- _warn(...params)
+ return function (newIgnores = []) {
+ newIgnores.forEach(key => {
+ if (!_ignoreList.includes(key))
+ _ignoreList.push(key)
+ })
+
+ if (!initialized) {
+ initialized = true
+ console.warn = function (...params) {
+ const msg = params[0]
+ const match = _ignoreList.filter(prop => msg.match(new RegExp(`was created with unknown prop '${prop}'`))).length
+ if (!match)
+ _warn(...params)
+ }
+ }
}
-}
+})()
+
+module.exports.demandObject = function (obj) {
+ const isObj = Object.prototype.toString.call(obj) === "[object Object]";
+ if (isObj || !obj) return true;
+ else
+ throw new Error(
+ `"${obj}" is not an object. "scoped" prop must an object`
+ );
+}
\ No newline at end of file