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