Skip to content

Commit

Permalink
Various fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
Maël Nison committed Jan 28, 2019
1 parent d2f4d37 commit 7aa617f
Show file tree
Hide file tree
Showing 6 changed files with 69 additions and 20 deletions.
15 changes: 15 additions & 0 deletions .pnp.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

33 changes: 23 additions & 10 deletions packages/berry-cli/bin/berry.js

Large diffs are not rendered by default.

24 changes: 14 additions & 10 deletions packages/berry-core/sources/Manifest.ts
Original file line number Diff line number Diff line change
Expand Up @@ -156,17 +156,21 @@ export class Manifest {
}
}

if (Array.isArray(data.workspaces)) {
for (const entry of data.workspaces) {
if (typeof entry !== `string`) {
errors.push(new Error(`Invalid workspace definition for '${entry}'`));
continue;
}

this.workspaceDefinitions.push({
pattern: entry,
});
const workspaces = Array.isArray(data.workspaces)
? data.workspaces
: typeof data.workspaces === `object` && data.workspaces !== null && Array.isArray(data.workspaces.packages)
? data.workspaces.packages
: [];

for (const entry of workspaces) {
if (typeof entry !== `string`) {
errors.push(new Error(`Invalid workspace definition for '${entry}'`));
continue;
}

this.workspaceDefinitions.push({
pattern: entry,
});
}

if (typeof data.dependenciesMeta === `object` && data.dependenciesMeta !== null) {
Expand Down
6 changes: 6 additions & 0 deletions packages/berry-pnp/sources/generatePnpScript.ts
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,12 @@ export function generatePnpScript(settings: PnpSettings): string {

return [
shebang ? `${shebang}\n\n` : ``,
`try {\n`,
` Object.freeze({}).detectStrictMode = true;\n`,
`} catch (error) {\n`,
` throw new Error(\`The whole PnP file got strict-mode-ified, which is known to break (Emscripten libraries aren't strict mode). This usually happens when the file goes through Babel.\`);\n`,
`}\n`,
`\n`,
`var __non_webpack_module__ = module;\n`,
`\n`,
`function $$DYNAMICALLY_GENERATED_CODE(topLevelLocator, blacklistedLocator) {\n`,
Expand Down
6 changes: 6 additions & 0 deletions packages/berry-pnp/sources/hook.ts
Original file line number Diff line number Diff line change
Expand Up @@ -856,6 +856,12 @@ export function setupCompatibilityLayer() {
if (__non_webpack_module__.parent && __non_webpack_module__.parent.id === 'internal/preload') {
setup();
setupCompatibilityLayer();

if (__non_webpack_module__.filename) {
// We delete it from the cache in order to support the case where the CLI resolver is invoked from "yarn run"
// It's annoying because it might cause some issues when the file is multiple times in NODE_OPTIONS, but it shouldn't happen anyway.
delete Module._cache[__non_webpack_module__.filename];
}
}

// @ts-ignore
Expand Down
5 changes: 5 additions & 0 deletions packages/berry-zipfs/sources/ZipFS.ts
Original file line number Diff line number Diff line change
Expand Up @@ -636,6 +636,11 @@ export class ZipFS extends FakeFS {
readFileSync(p: string, encoding: 'utf8'): string;
readFileSync(p: string, encoding?: string): Buffer;
readFileSync(p: string, encoding?: string) {
// This is messed up regarding the TS signatures
if (typeof encoding === `object`)
// @ts-ignore
encoding = encoding ? encoding.encoding : undefined;

const resolvedP = this.resolveFilename(`open '${p}'`, p);

if (!this.entries.has(resolvedP) && !this.listings.has(resolvedP))
Expand Down

0 comments on commit 7aa617f

Please sign in to comment.