Skip to content

Commit

Permalink
Merge branch 'v2' into atomic-write-stream
Browse files Browse the repository at this point in the history
  • Loading branch information
mischnic committed Jun 13, 2022
2 parents 85087d9 + 58bd6d7 commit ef74ee7
Show file tree
Hide file tree
Showing 34 changed files with 620 additions and 260 deletions.
165 changes: 89 additions & 76 deletions Cargo.lock

Large diffs are not rendered by default.

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

@@ -0,0 +1 @@
module.exports = Promise.resolve(require('./async')).then(x => x + 1335);
@@ -1,4 +1,4 @@
import {B} from './b.js';
import {C} from './c.js';

output = [new B()[Symbol.toStringTag], new C()[Symbol.toStringTag]];
output = [B[Symbol.toStringTag], C[Symbol.toStringTag]];
@@ -1,5 +1,3 @@
export class B {
get [Symbol.toStringTag]() {
return '1';
}
static [Symbol.toStringTag] = 1;
}
@@ -1,5 +1,3 @@
export class C {
get [Symbol.toStringTag]() {
return '2';
}
static [Symbol.toStringTag] = 2;
}
@@ -0,0 +1,18 @@
type Params = {
hello: number;
};
interface Hello {
yo: string;
}
export class Test {
test(hello: Hello): string;
}
export function test(params: Params): number;
export function foo(): number;
export var x: number;
export var hi: number;
export declare module mod {
function bar(): number;
}

//# sourceMappingURL=types.d.ts.map
@@ -0,0 +1 @@
export * from './src/index';
@@ -0,0 +1,6 @@
{
"name": "ts-types-main",
"private": true,
"main": "dist/main.js",
"types": "dist/types.d.ts"
}
@@ -0,0 +1,31 @@
type Params = {
hello: number;
};

interface Hello {
yo: string;
}

export class Test {
test(hello: Hello) {
return hello.yo;
}
}

export function test(params: Params) {
return params.hello;
}

export function foo() {
return 2;
}

var x = 2;
var p = x + 2, q = 3;
export {p as hi, x};

export module mod {
export function bar() {
return 2;
}
}
@@ -0,0 +1,9 @@
{
"compilerOptions": {
"removeComments": true,
"baseUrl": ".",
"paths": {
"@parcel/*": ["../../*"]
}
}
}
Empty file.
Expand Up @@ -26,6 +26,13 @@
"js": ["src/content.js"],
"css": ["src/content.css"]
}],
"declarative_net_request": {
"rule_resources": [{
"id": "ruleset_1",
"enabled": true,
"path": "./rulesets/ruleset_1.json"
}]
},
"dictionaries": {
"en-US": "./dicts/tmp.dic"
},
Expand Down
@@ -0,0 +1 @@
[]
23 changes: 23 additions & 0 deletions packages/core/integration-tests/test/javascript.js
Expand Up @@ -4630,6 +4630,29 @@ describe('javascript', function () {
assert.equal(await run(b), 5);
});

it('should properly chain a dynamic import wrapped in a Promise.resolve()', async () => {
let b = await bundle(
path.join(__dirname, '/integration/require-async/resolve-chain.js'),
);

assertBundles(b, [
{
name: 'resolve-chain.js',
assets: [
'resolve-chain.js',
'bundle-url.js',
'cacheLoader.js',
'js-loader.js',
],
},
{
assets: ['async.js'],
},
]);

assert.equal(await run(b), 1337);
});

it('should detect parcel style async requires in commonjs', async () => {
let b = await bundle(
path.join(__dirname, '/integration/require-async/parcel.js'),
Expand Down
22 changes: 22 additions & 0 deletions packages/core/integration-tests/test/ts-types.js
Expand Up @@ -388,4 +388,26 @@ describe('typescript types', function () {
);
assert.equal(dist, expected);
});

it('should handle a tsconfig file with paths on windows', async function () {
await bundle(
path.join(__dirname, '/integration/ts-types/windows-paths/index.ts'),
);

let dist = (
await outputFS.readFile(
path.join(
__dirname,
'/integration/ts-types/windows-paths/dist/types.d.ts',
),
'utf8',
)
).replace(/\r\n/g, '\n');

let expected = await inputFS.readFile(
path.join(__dirname, '/integration/ts-types/windows-paths/expected.d.ts'),
'utf8',
);
assert.equal(dist, expected);
});
});
7 changes: 7 additions & 0 deletions packages/core/integration-tests/test/webextension.js
Expand Up @@ -35,6 +35,9 @@ describe('webextension', function () {
{assets: ['devtools.html']},
{assets: ['content.js']},
{assets: ['content.css']},
{
assets: ['ruleset_1.json'],
},
]);
assert(
await outputFS.exists(
Expand All @@ -49,6 +52,10 @@ describe('webextension', function () {
);
const scripts = manifest.background.scripts;
assert.equal(scripts.length, 1);
for (const {path: resourcePath} of manifest.declarative_net_request
?.rule_resources ?? []) {
assert(await outputFS.exists(path.join(distDir, resourcePath)));
}
assert(
(
await outputFS.readFile(path.join(distDir, scripts[0]), 'utf-8')
Expand Down
26 changes: 19 additions & 7 deletions packages/core/utils/src/http-server.js
@@ -1,7 +1,15 @@
// @flow strict-local

import type {Server as HTTPOnlyServer} from 'http';
import type {Server as HTTPSServer} from 'https';
import type {
Server as HTTPOnlyServer,
IncomingMessage as HTTPRequest,
ServerResponse as HTTPResponse,
} from 'http';
import type {
Server as HTTPSServer,
IncomingMessage as HTTPSRequest,
ServerResponse as HTTPSResponse,
} from 'https';
import type {Socket} from 'net';
import type {FilePath, HTTPSOptions} from '@parcel/types';
import type {FileSystem} from '@parcel/fs';
Expand All @@ -12,12 +20,16 @@ import nullthrows from 'nullthrows';
import {getCertificate, generateCertificate} from './';

type CreateHTTPServerOpts = {|
https: ?(HTTPSOptions | boolean),
inputFS: FileSystem,
outputFS: FileSystem,
cacheDir: FilePath,
listener?: (mixed, mixed) => void,
listener?: (HTTPRequest | HTTPSRequest, HTTPResponse | HTTPSResponse) => void,
host?: string,
...
| {|
https: ?(HTTPSOptions | boolean),
inputFS: FileSystem,
outputFS: FileSystem,
cacheDir: FilePath,
|}
| {||},
|};

export type HTTPServer = HTTPOnlyServer | HTTPSServer;
Expand Down
11 changes: 7 additions & 4 deletions packages/packagers/webextension/src/WebExtensionPackager.js
Expand Up @@ -6,7 +6,7 @@ import {Packager} from '@parcel/plugin';
import {replaceURLReferences, relativeBundlePath} from '@parcel/utils';

export default (new Packager({
async package({bundle, bundleGraph}) {
async package({bundle, bundleGraph, options}) {
let assets = [];
bundle.traverseAssets(asset => {
assets.push(asset);
Expand Down Expand Up @@ -73,14 +73,17 @@ export default (new Packager({
}
}

if (manifest.manifest_version == 3 && options.hmrOptions) {
war.push({matches: ['<all_urls>'], resources: ['__parcel_hmr_proxy__']});
}

const warResult = (manifest.web_accessible_resources || []).concat(
manifest.manifest_version == 2
? [...new Set(war.flatMap(entry => entry.resources))]
: war,
);
if (warResult.length > 0) {
manifest.web_accessible_resources = warResult;
}

if (warResult.length > 0) manifest.web_accessible_resources = warResult;

let {contents} = replaceURLReferences({
bundle,
Expand Down

0 comments on commit ef74ee7

Please sign in to comment.