mirror of https://github.com/webpack/webpack.git
Merge pull request #14687 from webpack/bugfix/esm-single-quote
fix using single quotes with esm files
This commit is contained in:
commit
3c17f90bb3
|
@ -692,6 +692,11 @@ class SnapshotOptimization {
|
|||
}
|
||||
}
|
||||
|
||||
const parseString = str => {
|
||||
if (str[0] === "'") str = `"${str.slice(1, -1).replace(/"/g, '\\"')}"`;
|
||||
return JSON.parse(str);
|
||||
};
|
||||
|
||||
/* istanbul ignore next */
|
||||
/**
|
||||
* @param {number} mtime mtime
|
||||
|
@ -1657,17 +1662,13 @@ class FileSystemInfo {
|
|||
let dependency;
|
||||
if (imp.d === -1) {
|
||||
// import ... from "..."
|
||||
dependency = JSON.parse(
|
||||
dependency = parseString(
|
||||
source.substring(imp.s - 1, imp.e + 1)
|
||||
);
|
||||
} else if (imp.d > -1) {
|
||||
// import()
|
||||
let expr = source.substring(imp.s, imp.e).trim();
|
||||
if (expr[0] === "'")
|
||||
expr = `"${expr
|
||||
.slice(1, -1)
|
||||
.replace(/"/g, '\\"')}"`;
|
||||
dependency = JSON.parse(expr);
|
||||
dependency = parseString(expr);
|
||||
} else {
|
||||
// e.g. import.meta
|
||||
continue;
|
||||
|
|
|
@ -1,5 +1,9 @@
|
|||
export { default } from "./esm-dep.mjs";
|
||||
// prettier-ignore
|
||||
import './esm-dep.mjs';
|
||||
|
||||
export const asyncDep = (
|
||||
await import("../../js/buildDepsInput/esm-async-dependency.mjs")
|
||||
).default;
|
||||
// prettier-ignore
|
||||
await import('../../js/buildDepsInput/esm-async-dependency.mjs')
|
||||
|
|
Loading…
Reference in New Issue