svelte-loader
Advanced tools
Comparing version 3.1.6 to 3.1.7
25
index.js
const path = require('path'); | ||
const fs = require('fs'); | ||
const { getOptions } = require('loader-utils'); | ||
@@ -27,6 +28,26 @@ const { buildMakeHot } = require('./lib/make-hot.js'); | ||
try { | ||
const config = require(path.resolve(process.cwd(), configFile)); | ||
if (!config.resolve || !config.resolve.conditionNames || !config.resolve.conditionNames.includes('svelte')) { | ||
const configPath = path.resolve(process.cwd(), configFile); | ||
const config = require(configPath); | ||
let found = false; | ||
if (Array.isArray(config)) { | ||
found = config.some(check); | ||
} else { | ||
found = check(config); | ||
} | ||
if (!found) { | ||
console.warn('\n\u001B[1m\u001B[31mWARNING: You should add "svelte" to the "resolve.conditionNames" array in your webpack config. See https://github.com/sveltejs/svelte-loader#resolveconditionnames for more information\u001B[39m\u001B[22m\n'); | ||
} | ||
function check(config) { | ||
if (typeof config === 'function') { | ||
// We could try to invoke it but that could maybe have side unintended side effects | ||
// and/or fail due to missing parameters, so we read the file instead | ||
const configString = fs.readFileSync(configPath, 'utf-8'); | ||
const result = /conditionNames\s*:[\s|\n]*\[([^\]]+?)\]/.exec(configString); | ||
return !!result && !!result[1].includes('svelte'); | ||
} else { | ||
return !!config.resolve && !!config.resolve.conditionNames && config.resolve.conditionNames.includes('svelte'); | ||
} | ||
} | ||
} catch (e) { | ||
@@ -33,0 +54,0 @@ // do nothing and hope for the best |
@@ -0,0 +0,0 @@ import { makeApplyHmr } from 'svelte-hmr/runtime'; |
@@ -0,0 +0,0 @@ const { walk } = require('svelte/compiler'); |
@@ -0,0 +0,0 @@ Copyright (c) 2016-21 [these people](https://github.com/sveltejs/svelte-loader/graphs/contributors) |
{ | ||
"name": "svelte-loader", | ||
"version": "3.1.6", | ||
"version": "3.1.7", | ||
"author": "Nico Rehwaldt <git_nikku@nixis.de>", | ||
@@ -5,0 +5,0 @@ "description": "A webpack loader for svelte", |
@@ -0,0 +0,0 @@ > Undecided yet what bundler to use? We suggest using [SvelteKit](https://kit.svelte.dev), or Vite with [vite-plugin-svelte](https://github.com/sveltejs/vite-plugin-svelte/). |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
Dynamic require
Supply chain riskDynamic require can indicate the package is performing dangerous or unsafe dynamic code execution.
Found 1 instance in 1 package
Filesystem access
Supply chain riskAccesses the file system, and could potentially read sensitive data.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
Dynamic require
Supply chain riskDynamic require can indicate the package is performing dangerous or unsafe dynamic code execution.
Found 1 instance in 1 package
20392
207
3