forked from external-repos/squoosh
Fixing windows build (#849)
Co-authored-by: Ingvar Stepanyan <rreverser@google.com>
This commit is contained in:
@@ -11,6 +11,7 @@
|
||||
* limitations under the License.
|
||||
*/
|
||||
import rollup from 'rollup';
|
||||
import * as path from 'path';
|
||||
|
||||
const prefix = 'client-bundle:';
|
||||
const entryPathPlaceholder = 'CLIENT_BUNDLE_PLUGIN_ENTRY_PATH';
|
||||
@@ -119,9 +120,10 @@ export default function (inputOptions, outputOptions, resolveFileUrl) {
|
||||
return;
|
||||
}
|
||||
|
||||
const id = entryPointPlaceholderMap.get(num);
|
||||
const id = path.normalize(entryPointPlaceholderMap.get(num));
|
||||
const clientEntry = clientOutput.find(
|
||||
(item) => item.facadeModuleId === id,
|
||||
(item) =>
|
||||
item.facadeModuleId && path.normalize(item.facadeModuleId) === id,
|
||||
);
|
||||
|
||||
if (property.startsWith(entryPathPlaceholder)) {
|
||||
|
||||
@@ -18,6 +18,8 @@ import {
|
||||
resolve as resolvePath,
|
||||
dirname,
|
||||
normalize as nomalizePath,
|
||||
sep as pathSep,
|
||||
posix,
|
||||
} from 'path';
|
||||
|
||||
import postcss from 'postcss';
|
||||
@@ -172,14 +174,15 @@ export default function (resolveFileUrl) {
|
||||
return `export default ${cssStr};`;
|
||||
}
|
||||
if (id.startsWith(addPrefix)) {
|
||||
const path = id.slice(addPrefix.length);
|
||||
const path = nomalizePath(id.slice(addPrefix.length));
|
||||
return (
|
||||
`import css from 'css:${path}';\n` +
|
||||
`import css from ${JSON.stringify('css:' + path)};\n` +
|
||||
`import appendCss from '${appendCssModule}';\n` +
|
||||
`appendCss(css);\n`
|
||||
);
|
||||
}
|
||||
if (id.endsWith(moduleSuffix)) {
|
||||
const path = nomalizePath(id.slice(0, -moduleSuffix.length));
|
||||
if (!pathToResult.has(id)) {
|
||||
throw Error(`Cannot find ${id} in pathToResult`);
|
||||
}
|
||||
|
||||
@@ -19,15 +19,16 @@ import glob from 'glob';
|
||||
const globP = promisify(glob);
|
||||
|
||||
const moduleId = 'initial-css:';
|
||||
const initialCssModule = '\0initialCss';
|
||||
|
||||
export default function initialCssPlugin() {
|
||||
return {
|
||||
name: 'initial-css-plugin',
|
||||
resolveId(id) {
|
||||
if (id === moduleId) return moduleId;
|
||||
if (id === moduleId) return initialCssModule;
|
||||
},
|
||||
async load(id) {
|
||||
if (id !== moduleId) return;
|
||||
if (id !== initialCssModule) return;
|
||||
|
||||
const matches = await globP('shared/initial-app/**/*.css', {
|
||||
nodir: true,
|
||||
|
||||
@@ -10,7 +10,7 @@
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
import { posix as pathUtils } from 'path';
|
||||
import { posix as pathUtils, isAbsolute } from 'path';
|
||||
|
||||
export default function resolveDirs(paths) {
|
||||
const pathBaseDir = paths.map((path) => [
|
||||
@@ -30,6 +30,7 @@ export default function resolveDirs(paths) {
|
||||
if (!resolveResult) {
|
||||
throw new Error(`Couldn't find ${'./' + id}`);
|
||||
}
|
||||
if (isAbsolute(resolveResult.id)) return resolveResult.id;
|
||||
return pathUtils.resolve(resolveResult.id);
|
||||
},
|
||||
};
|
||||
|
||||
@@ -127,15 +127,6 @@ export default function simpleTS(mainPath, { noBuild, watch } = {}) {
|
||||
relative(process.cwd(), id),
|
||||
).replace(extRe, '.js');
|
||||
|
||||
console.log(
|
||||
`simple-ts mapping`,
|
||||
id,
|
||||
'to',
|
||||
newId,
|
||||
'with outDir',
|
||||
config.options.outDir,
|
||||
);
|
||||
|
||||
return fsp.readFile(newId, { encoding: 'utf8' });
|
||||
},
|
||||
};
|
||||
|
||||
@@ -52,7 +52,7 @@ function jsFileName(chunkInfo) {
|
||||
const parsedPath = path.parse(chunkInfo.facadeModuleId);
|
||||
if (parsedPath.name !== 'index') return jsPath;
|
||||
// Come up with a better name than 'index'
|
||||
const name = parsedPath.dir.split('/').slice(-1);
|
||||
const name = parsedPath.dir.split(/\\|\//).slice(-1);
|
||||
return jsPath.replace('[name]', name);
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user