Align eslint and prettier rules with turborepo (vercel/turbo#397)
This commit is contained in:
parent
a9b5ada56a
commit
b9c36e7748
103 changed files with 666 additions and 696 deletions
|
@ -1,5 +1,5 @@
|
|||
import Component from '.'
|
||||
import { hydrateRoot } from 'react-dom/client'
|
||||
import Component from ".";
|
||||
import { hydrateRoot } from "react-dom/client";
|
||||
|
||||
const data = JSON.parse(document.getElementById('__NEXT_DATA__').textContent)
|
||||
hydrateRoot(document.getElementById('__next'), <Component {...data.props} />)
|
||||
const data = JSON.parse(document.getElementById("__NEXT_DATA__").textContent);
|
||||
hydrateRoot(document.getElementById("__next"), <Component {...data.props} />);
|
||||
|
|
|
@ -1,50 +1,50 @@
|
|||
const END_OF_OPERATION = process.argv[2]
|
||||
const END_OF_OPERATION = process.argv[2];
|
||||
|
||||
import Component, * as otherExports from '.'
|
||||
import { renderToString, renderToStaticMarkup } from 'react-dom/server'
|
||||
;('TURBOPACK { transition: next-client }')
|
||||
import chunkGroup from '.'
|
||||
import Component, * as otherExports from ".";
|
||||
import { renderToString, renderToStaticMarkup } from "react-dom/server";
|
||||
("TURBOPACK { transition: next-client }");
|
||||
import chunkGroup from ".";
|
||||
|
||||
process.stdout.write('READY\n')
|
||||
process.stdout.write("READY\n");
|
||||
|
||||
const NEW_LINE = '\n'.charCodeAt(0)
|
||||
let buffer = []
|
||||
process.stdin.on('data', async (data) => {
|
||||
let idx = data.indexOf(NEW_LINE)
|
||||
const NEW_LINE = "\n".charCodeAt(0);
|
||||
let buffer = [];
|
||||
process.stdin.on("data", async (data) => {
|
||||
let idx = data.indexOf(NEW_LINE);
|
||||
while (idx >= 0) {
|
||||
buffer.push(data.slice(0, idx))
|
||||
buffer.push(data.slice(0, idx));
|
||||
try {
|
||||
let json = JSON.parse(Buffer.concat(buffer).toString('utf-8'))
|
||||
let result = await operation(json)
|
||||
console.log(`RESULT=${JSON.stringify(result)}`)
|
||||
let json = JSON.parse(Buffer.concat(buffer).toString("utf-8"));
|
||||
let result = await operation(json);
|
||||
console.log(`RESULT=${JSON.stringify(result)}`);
|
||||
} catch (e) {
|
||||
console.log(`ERROR=${JSON.stringify(e.stack)}`)
|
||||
console.log(`ERROR=${JSON.stringify(e.stack)}`);
|
||||
}
|
||||
console.log(END_OF_OPERATION)
|
||||
data = data.slice(idx + 1)
|
||||
idx = data.indexOf(NEW_LINE)
|
||||
console.log(END_OF_OPERATION);
|
||||
data = data.slice(idx + 1);
|
||||
idx = data.indexOf(NEW_LINE);
|
||||
}
|
||||
buffer.push(data)
|
||||
})
|
||||
buffer.push(data);
|
||||
});
|
||||
|
||||
async function operation(data) {
|
||||
let staticProps = data
|
||||
if ('getStaticProps' in otherExports) {
|
||||
let staticProps = data;
|
||||
if ("getStaticProps" in otherExports) {
|
||||
// TODO(alexkirsz) Pass in `context` as defined in
|
||||
// https://nextjs.org/docs/api-reference/data-fetching/get-static-props#context-parameter
|
||||
staticProps = otherExports.getStaticProps({})
|
||||
if ('then' in staticProps) {
|
||||
staticProps = await staticProps
|
||||
staticProps = otherExports.getStaticProps({});
|
||||
if ("then" in staticProps) {
|
||||
staticProps = await staticProps;
|
||||
}
|
||||
}
|
||||
|
||||
// TODO capture meta info during rendering
|
||||
const rendered = {
|
||||
__html: renderToString(<Component {...staticProps.props} />),
|
||||
}
|
||||
const urls = chunkGroup.map((p) => `/${p}`)
|
||||
const scripts = urls.filter((url) => url.endsWith('.js'))
|
||||
const styles = urls.filter((url) => url.endsWith('.css'))
|
||||
};
|
||||
const urls = chunkGroup.map((p) => `/${p}`);
|
||||
const scripts = urls.filter((url) => url.endsWith(".js"));
|
||||
const styles = urls.filter((url) => url.endsWith(".css"));
|
||||
return renderToStaticMarkup(
|
||||
<html>
|
||||
<head>
|
||||
|
@ -68,23 +68,23 @@ async function operation(data) {
|
|||
<script key={url} src={url} type="text/javascript"></script>
|
||||
))}
|
||||
</body>
|
||||
</html>,
|
||||
)
|
||||
</html>
|
||||
);
|
||||
}
|
||||
|
||||
// This utility is based on https://github.com/zertosh/htmlescape
|
||||
// License: https://github.com/zertosh/htmlescape/blob/0527ca7156a524d256101bb310a9f970f63078ad/LICENSE
|
||||
|
||||
const ESCAPE_LOOKUP = {
|
||||
'&': '\\u0026',
|
||||
'>': '\\u003e',
|
||||
'<': '\\u003c',
|
||||
'\u2028': '\\u2028',
|
||||
'\u2029': '\\u2029',
|
||||
}
|
||||
"&": "\\u0026",
|
||||
">": "\\u003e",
|
||||
"<": "\\u003c",
|
||||
"\u2028": "\\u2028",
|
||||
"\u2029": "\\u2029",
|
||||
};
|
||||
|
||||
const ESCAPE_REGEX = /[&><\u2028\u2029]/g
|
||||
const ESCAPE_REGEX = /[&><\u2028\u2029]/g;
|
||||
|
||||
export function htmlEscapeJsonString(str) {
|
||||
return str.replace(ESCAPE_REGEX, (match) => ESCAPE_LOOKUP[match])
|
||||
return str.replace(ESCAPE_REGEX, (match) => ESCAPE_LOOKUP[match]);
|
||||
}
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
import { defineConfig } from 'vite'
|
||||
import react from '@vitejs/plugin-react'
|
||||
import { defineConfig } from "vite";
|
||||
import react from "@vitejs/plugin-react";
|
||||
|
||||
export default defineConfig({
|
||||
plugins: [react()],
|
||||
})
|
||||
});
|
||||
|
|
|
@ -1,20 +1,20 @@
|
|||
const ReactRefreshWebpackPlugin = require('@pmmmwh/react-refresh-webpack-plugin')
|
||||
const ReactRefreshWebpackPlugin = require("@pmmmwh/react-refresh-webpack-plugin");
|
||||
|
||||
module.exports = {
|
||||
mode: 'development',
|
||||
mode: "development",
|
||||
resolve: {
|
||||
extensions: ['.jsx', '...'],
|
||||
extensions: [".jsx", "..."],
|
||||
},
|
||||
module: {
|
||||
unsafeCache: true,
|
||||
rules: [
|
||||
{
|
||||
test: /\.jsx$/,
|
||||
loader: 'swc-loader',
|
||||
loader: "swc-loader",
|
||||
options: {
|
||||
jsc: {
|
||||
parser: {
|
||||
syntax: 'ecmascript',
|
||||
syntax: "ecmascript",
|
||||
jsx: true,
|
||||
dynamicImport: true,
|
||||
privateMethod: true,
|
||||
|
@ -29,7 +29,7 @@ module.exports = {
|
|||
externalHelpers: true,
|
||||
transform: {
|
||||
react: {
|
||||
runtime: 'automatic',
|
||||
runtime: "automatic",
|
||||
refresh: true,
|
||||
},
|
||||
},
|
||||
|
@ -42,7 +42,7 @@ module.exports = {
|
|||
hot: true,
|
||||
},
|
||||
cache: {
|
||||
type: 'filesystem',
|
||||
type: "filesystem",
|
||||
},
|
||||
node: {
|
||||
global: true,
|
||||
|
@ -51,4 +51,4 @@ module.exports = {
|
|||
futureDefaults: true,
|
||||
},
|
||||
plugins: [new ReactRefreshWebpackPlugin()],
|
||||
}
|
||||
};
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
import * as jest from 'jest-circus-browser/dist/umd/jest-circus.js'
|
||||
import expect from 'expect/build-es5/index.js'
|
||||
import * as jest from "jest-circus-browser/dist/umd/jest-circus.js";
|
||||
import expect from "expect/build-es5/index.js";
|
||||
|
||||
globalThis.__jest__ = jest
|
||||
globalThis.expect = expect
|
||||
globalThis.describe = jest.describe
|
||||
globalThis.it = jest.it
|
||||
globalThis.__jest__ = jest;
|
||||
globalThis.expect = expect;
|
||||
globalThis.describe = jest.describe;
|
||||
globalThis.it = jest.it;
|
||||
|
|
|
@ -1,19 +1,19 @@
|
|||
it('runs sync tests', () => {
|
||||
expect(true).toBe(true)
|
||||
})
|
||||
it("runs sync tests", () => {
|
||||
expect(true).toBe(true);
|
||||
});
|
||||
|
||||
it('runs async tests', async () => {
|
||||
await Promise.resolve()
|
||||
expect(true).toBe(true)
|
||||
})
|
||||
it("runs async tests", async () => {
|
||||
await Promise.resolve();
|
||||
expect(true).toBe(true);
|
||||
});
|
||||
|
||||
describe('nested describe', () => {
|
||||
it('runs sync tests', () => {
|
||||
expect(true).toBe(true)
|
||||
})
|
||||
describe("nested describe", () => {
|
||||
it("runs sync tests", () => {
|
||||
expect(true).toBe(true);
|
||||
});
|
||||
|
||||
it('runs async tests', async () => {
|
||||
await Promise.resolve()
|
||||
expect(true).toBe(true)
|
||||
})
|
||||
})
|
||||
it("runs async tests", async () => {
|
||||
await Promise.resolve();
|
||||
expect(true).toBe(true);
|
||||
});
|
||||
});
|
||||
|
|
|
@ -1,8 +1,8 @@
|
|||
import React from 'react'
|
||||
import TestRenderer from 'react-test-renderer'
|
||||
import React from "react";
|
||||
import TestRenderer from "react-test-renderer";
|
||||
|
||||
describe('styled-jsx', () => {
|
||||
it('compiles away <style jsx>', () => {
|
||||
describe("styled-jsx", () => {
|
||||
it("compiles away <style jsx>", () => {
|
||||
const test = TestRenderer.create(
|
||||
<>
|
||||
<span>This should be color: red</span>
|
||||
|
@ -11,15 +11,15 @@ describe('styled-jsx', () => {
|
|||
color: red;
|
||||
}
|
||||
`}</style>
|
||||
</>,
|
||||
)
|
||||
</>
|
||||
);
|
||||
|
||||
expect(test.toJSON()).toMatchObject({
|
||||
children: ['This should be color: red'],
|
||||
children: ["This should be color: red"],
|
||||
props: {
|
||||
className: /jsx\-[0-9a-f]+/,
|
||||
},
|
||||
type: 'span',
|
||||
})
|
||||
})
|
||||
})
|
||||
type: "span",
|
||||
});
|
||||
});
|
||||
});
|
||||
|
|
|
@ -1 +1 @@
|
|||
module.exports = 4
|
||||
module.exports = 4;
|
||||
|
|
|
@ -1,29 +1,29 @@
|
|||
it("should not bundle context requires with asyncMode === 'weak'", function () {
|
||||
var contextRequire = require.context('.', false, /two/, 'weak')
|
||||
var contextRequire = require.context(".", false, /two/, "weak");
|
||||
expect(function () {
|
||||
contextRequire('./two')
|
||||
}).toThrowError(/not available/)
|
||||
})
|
||||
contextRequire("./two");
|
||||
}).toThrowError(/not available/);
|
||||
});
|
||||
|
||||
it("should not bundle context requires with asyncMode === 'weak' using import.meta.webpackContext", function () {
|
||||
const contextRequire = import.meta.webpackContext('.', {
|
||||
const contextRequire = import.meta.webpackContext(".", {
|
||||
recursive: false,
|
||||
regExp: /two/,
|
||||
mode: 'weak',
|
||||
})
|
||||
mode: "weak",
|
||||
});
|
||||
expect(function () {
|
||||
contextRequire('./two')
|
||||
}).toThrowError(/not available/)
|
||||
})
|
||||
contextRequire("./two");
|
||||
}).toThrowError(/not available/);
|
||||
});
|
||||
|
||||
it("should find module with asyncMode === 'weak' when required elsewhere", function () {
|
||||
var contextRequire = require.context('.', false, /.+/, 'weak')
|
||||
expect(contextRequire('./three')).toBe(3)
|
||||
require('./three') // in a real app would be served as a separate chunk
|
||||
})
|
||||
var contextRequire = require.context(".", false, /.+/, "weak");
|
||||
expect(contextRequire("./three")).toBe(3);
|
||||
require("./three"); // in a real app would be served as a separate chunk
|
||||
});
|
||||
|
||||
it("should find module with asyncMode === 'weak' when required elsewhere (recursive)", function () {
|
||||
var contextRequire = require.context('.', true, /.+/, 'weak')
|
||||
expect(contextRequire('./dir/four')).toBe(4)
|
||||
require('./dir/four') // in a real app would be served as a separate chunk
|
||||
})
|
||||
var contextRequire = require.context(".", true, /.+/, "weak");
|
||||
expect(contextRequire("./dir/four")).toBe(4);
|
||||
require("./dir/four"); // in a real app would be served as a separate chunk
|
||||
});
|
||||
|
|
|
@ -1 +1 @@
|
|||
module.exports = 3
|
||||
module.exports = 3;
|
||||
|
|
|
@ -1 +1 @@
|
|||
module.exports = 2
|
||||
module.exports = 2;
|
||||
|
|
|
@ -1,9 +1,9 @@
|
|||
it('should also work in a chunk', function (done) {
|
||||
it("should also work in a chunk", function (done) {
|
||||
require.ensure([], function (require) {
|
||||
var contextRequire = require.context('.', false, /two/)
|
||||
expect(contextRequire('./two')).toBe(2)
|
||||
var tw = 'tw'
|
||||
expect(require('.' + '/' + tw + 'o')).toBe(2)
|
||||
done()
|
||||
})
|
||||
})
|
||||
var contextRequire = require.context(".", false, /two/);
|
||||
expect(contextRequire("./two")).toBe(2);
|
||||
var tw = "tw";
|
||||
expect(require("." + "/" + tw + "o")).toBe(2);
|
||||
done();
|
||||
});
|
||||
});
|
||||
|
|
|
@ -1 +1 @@
|
|||
module.exports = 2
|
||||
module.exports = 2;
|
||||
|
|
|
@ -1,11 +1,11 @@
|
|||
import leftHelix from './leftHelix'
|
||||
import rightHelix from './rightHelix'
|
||||
import leftHelix from "./leftHelix";
|
||||
import rightHelix from "./rightHelix";
|
||||
|
||||
it('should import generate ensure function for this', () => {
|
||||
return Promise.all([leftHelix.run(), rightHelix.run()])
|
||||
})
|
||||
it("should import generate ensure function for this", () => {
|
||||
return Promise.all([leftHelix.run(), rightHelix.run()]);
|
||||
});
|
||||
|
||||
export default {
|
||||
leftHelix,
|
||||
rightHelix,
|
||||
}
|
||||
};
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
import leftHelixPrime, { run } from './leftHelixPrime'
|
||||
import leftHelixPrime, { run } from "./leftHelixPrime";
|
||||
|
||||
export default {
|
||||
leftHelixPrime,
|
||||
run,
|
||||
}
|
||||
};
|
||||
|
|
|
@ -1,9 +1,9 @@
|
|||
import rightHelixPrime from './rightHelixPrime'
|
||||
import rightHelixPrime from "./rightHelixPrime";
|
||||
|
||||
export function run() {
|
||||
return import(/* webpackChunkName: "left" */ './leftHelix')
|
||||
return import(/* webpackChunkName: "left" */ "./leftHelix");
|
||||
}
|
||||
|
||||
export default {
|
||||
rightHelixPrime: () => rightHelixPrime,
|
||||
}
|
||||
};
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
import rightHelixPrime, { run } from './rightHelixPrime'
|
||||
import rightHelixPrime, { run } from "./rightHelixPrime";
|
||||
|
||||
export default {
|
||||
rightHelixPrime,
|
||||
run,
|
||||
}
|
||||
};
|
||||
|
|
|
@ -1,9 +1,9 @@
|
|||
import leftHelixPrime from './leftHelixPrime'
|
||||
import leftHelixPrime from "./leftHelixPrime";
|
||||
|
||||
export function run() {
|
||||
return import(/* webpackChunkName: "right" */ './rightHelix')
|
||||
return import(/* webpackChunkName: "right" */ "./rightHelix");
|
||||
}
|
||||
|
||||
export default {
|
||||
leftHelixPrime: () => leftHelixPrime,
|
||||
}
|
||||
};
|
||||
|
|
|
@ -1 +1 @@
|
|||
export default 'initialModuleDefault'
|
||||
export default "initialModuleDefault";
|
||||
|
|
|
@ -1 +1 @@
|
|||
exports.default = 'other'
|
||||
exports.default = "other";
|
||||
|
|
|
@ -1 +1 @@
|
|||
export default 'initialModuleDefault'
|
||||
export default "initialModuleDefault";
|
||||
|
|
|
@ -1,21 +1,21 @@
|
|||
it('should resolve when import existed chunk (#8626)', function (done) {
|
||||
require.context('./dir-initial/')
|
||||
const fileName = 'initialModule'
|
||||
it("should resolve when import existed chunk (#8626)", function (done) {
|
||||
require.context("./dir-initial/");
|
||||
const fileName = "initialModule";
|
||||
import(`./dir-initial/${fileName}`)
|
||||
.then(({ default: m }) => {
|
||||
expect(m).toBe('initialModuleDefault')
|
||||
done()
|
||||
expect(m).toBe("initialModuleDefault");
|
||||
done();
|
||||
})
|
||||
.catch(done)
|
||||
})
|
||||
.catch(done);
|
||||
});
|
||||
|
||||
it('should resolve when import existed chunk with fake maps', function (done) {
|
||||
require.context('./dir-initial-with-fake-map/')
|
||||
const fileName = 'initialModule'
|
||||
it("should resolve when import existed chunk with fake maps", function (done) {
|
||||
require.context("./dir-initial-with-fake-map/");
|
||||
const fileName = "initialModule";
|
||||
import(`./dir-initial-with-fake-map/${fileName}`)
|
||||
.then(({ default: m }) => {
|
||||
expect(m).toBe('initialModuleDefault')
|
||||
done()
|
||||
expect(m).toBe("initialModuleDefault");
|
||||
done();
|
||||
})
|
||||
.catch(done)
|
||||
})
|
||||
.catch(done);
|
||||
});
|
||||
|
|
|
@ -1 +1 @@
|
|||
module.exports = 1
|
||||
module.exports = 1;
|
||||
|
|
|
@ -1 +1 @@
|
|||
module.exports = 3
|
||||
module.exports = 3;
|
||||
|
|
|
@ -1 +1 @@
|
|||
module.exports = 2
|
||||
module.exports = 2;
|
||||
|
|
|
@ -1 +1 @@
|
|||
module.exports = 1
|
||||
module.exports = 1;
|
||||
|
|
|
@ -1 +1 @@
|
|||
module.exports = 3
|
||||
module.exports = 3;
|
||||
|
|
|
@ -1 +1 @@
|
|||
module.exports = 2
|
||||
module.exports = 2;
|
||||
|
|
|
@ -1,42 +1,42 @@
|
|||
function testCase(load, done) {
|
||||
load('two', 2, function () {
|
||||
var sync = true
|
||||
load('one', 1, function () {
|
||||
expect(sync).toBe(false)
|
||||
load('three', 3, function () {
|
||||
var sync = true
|
||||
load('two', 2, function () {
|
||||
expect(sync).toBe(true)
|
||||
done()
|
||||
})
|
||||
load("two", 2, function () {
|
||||
var sync = true;
|
||||
load("one", 1, function () {
|
||||
expect(sync).toBe(false);
|
||||
load("three", 3, function () {
|
||||
var sync = true;
|
||||
load("two", 2, function () {
|
||||
expect(sync).toBe(true);
|
||||
done();
|
||||
});
|
||||
Promise.resolve()
|
||||
.then(function () {})
|
||||
.then(function () {})
|
||||
.then(function () {
|
||||
sync = false
|
||||
})
|
||||
})
|
||||
})
|
||||
sync = false;
|
||||
});
|
||||
});
|
||||
});
|
||||
Promise.resolve().then(function () {
|
||||
sync = false
|
||||
})
|
||||
})
|
||||
sync = false;
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
it('should be able to use expressions in import', function (done) {
|
||||
it("should be able to use expressions in import", function (done) {
|
||||
function load(name, expected, callback) {
|
||||
import('./dir/' + name)
|
||||
import("./dir/" + name)
|
||||
.then(function (result) {
|
||||
expect(result).toEqual(
|
||||
nsObj({
|
||||
default: expected,
|
||||
}),
|
||||
)
|
||||
callback()
|
||||
})
|
||||
);
|
||||
callback();
|
||||
})
|
||||
.catch(function (err) {
|
||||
done(err)
|
||||
})
|
||||
done(err);
|
||||
});
|
||||
}
|
||||
testCase(load, done)
|
||||
})
|
||||
testCase(load, done);
|
||||
});
|
||||
|
|
|
@ -1,14 +1,14 @@
|
|||
it('should be able to use import', function (done) {
|
||||
import('./two')
|
||||
it("should be able to use import", function (done) {
|
||||
import("./two")
|
||||
.then(function (two) {
|
||||
expect(two).toEqual(
|
||||
nsObj({
|
||||
default: 2,
|
||||
}),
|
||||
)
|
||||
done()
|
||||
})
|
||||
);
|
||||
done();
|
||||
})
|
||||
.catch(function (err) {
|
||||
done(err)
|
||||
})
|
||||
})
|
||||
done(err);
|
||||
});
|
||||
});
|
||||
|
|
|
@ -1 +1 @@
|
|||
module.exports = 2
|
||||
module.exports = 2;
|
||||
|
|
|
@ -1 +1 @@
|
|||
export default 'a'
|
||||
export default "a";
|
||||
|
|
|
@ -1 +1 @@
|
|||
export default 'b'
|
||||
export default "b";
|
||||
|
|
|
@ -1 +1 @@
|
|||
export default 'c'
|
||||
export default "c";
|
||||
|
|
|
@ -1 +1 @@
|
|||
export default 'd'
|
||||
export default "d";
|
||||
|
|
|
@ -1 +1 @@
|
|||
export default 'a'
|
||||
export default "a";
|
||||
|
|
|
@ -1 +1 @@
|
|||
export default 'a'
|
||||
export default "a";
|
||||
|
|
|
@ -1,9 +1,9 @@
|
|||
export const c = 'c'
|
||||
export const c = "c";
|
||||
|
||||
export const d = 'd'
|
||||
export const d = "d";
|
||||
|
||||
export const longnameforexport = 'longnameforexport'
|
||||
export const longnameforexport = "longnameforexport";
|
||||
|
||||
export default 'default2'
|
||||
export default "default2";
|
||||
|
||||
export const usedExports = __webpack_exports_info__.usedExports
|
||||
export const usedExports = __webpack_exports_info__.usedExports;
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
export const c = 'c'
|
||||
export const c = "c";
|
||||
|
||||
export const d = 'd'
|
||||
export const d = "d";
|
||||
|
||||
export default 'default2'
|
||||
export default "default2";
|
||||
|
||||
export const usedExports = __webpack_exports_info__.usedExports
|
||||
export const usedExports = __webpack_exports_info__.usedExports;
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
export const a = 'a'
|
||||
export const a = "a";
|
||||
|
||||
export const b = 'b'
|
||||
export const b = "b";
|
||||
|
||||
export default 'default'
|
||||
export default "default";
|
||||
|
||||
export const usedExports = __webpack_exports_info__.usedExports
|
||||
export const usedExports = __webpack_exports_info__.usedExports;
|
||||
|
|
|
@ -1 +1 @@
|
|||
export default 'a'
|
||||
export default "a";
|
||||
|
|
|
@ -1 +1 @@
|
|||
export default 'b'
|
||||
export default "b";
|
||||
|
|
|
@ -1 +1 @@
|
|||
export default 'c'
|
||||
export default "c";
|
||||
|
|
|
@ -1 +1 @@
|
|||
export default 'd'
|
||||
export default "d";
|
||||
|
|
|
@ -1 +1 @@
|
|||
export default 'a'
|
||||
export default "a";
|
||||
|
|
|
@ -1 +1 @@
|
|||
export default 'b'
|
||||
export default "b";
|
||||
|
|
|
@ -1 +1 @@
|
|||
export default 'c'
|
||||
export default "c";
|
||||
|
|
|
@ -1 +1 @@
|
|||
export default 'd'
|
||||
export default "d";
|
||||
|
|
|
@ -1 +1 @@
|
|||
export default 'a'
|
||||
export default "a";
|
||||
|
|
|
@ -1 +1 @@
|
|||
export default 'b'
|
||||
export default "b";
|
||||
|
|
|
@ -1 +1 @@
|
|||
export default 'c'
|
||||
export default "c";
|
||||
|
|
|
@ -1 +1 @@
|
|||
export default 'd'
|
||||
export default "d";
|
||||
|
|
|
@ -1 +1 @@
|
|||
export default 'a'
|
||||
export default "a";
|
||||
|
|
|
@ -1 +1 @@
|
|||
export default 'b'
|
||||
export default "b";
|
||||
|
|
|
@ -1 +1 @@
|
|||
export default 'c'
|
||||
export default "c";
|
||||
|
|
|
@ -1 +1 @@
|
|||
export default 'd'
|
||||
export default "d";
|
||||
|
|
|
@ -1 +1 @@
|
|||
export default 'a'
|
||||
export default "a";
|
||||
|
|
|
@ -1 +1 @@
|
|||
export default 'b'
|
||||
export default "b";
|
||||
|
|
|
@ -1 +1 @@
|
|||
export default 'c'
|
||||
export default "c";
|
||||
|
|
|
@ -1 +1 @@
|
|||
export default 'd'
|
||||
export default "d";
|
||||
|
|
|
@ -1 +1 @@
|
|||
export default 'a'
|
||||
export default "a";
|
||||
|
|
|
@ -1 +1 @@
|
|||
export default 'b'
|
||||
export default "b";
|
||||
|
|
|
@ -1 +1 @@
|
|||
export default 'c'
|
||||
export default "c";
|
||||
|
|
|
@ -1 +1 @@
|
|||
export default 'd'
|
||||
export default "d";
|
||||
|
|
|
@ -1 +1 @@
|
|||
export default 'a'
|
||||
export default "a";
|
||||
|
|
|
@ -1 +1 @@
|
|||
export default 'b'
|
||||
export default "b";
|
||||
|
|
|
@ -1 +1 @@
|
|||
export default 'c'
|
||||
export default "c";
|
||||
|
|
|
@ -1 +1 @@
|
|||
export default 'a'
|
||||
export default "a";
|
||||
|
|
|
@ -1 +1 @@
|
|||
export default 'b'
|
||||
export default "b";
|
||||
|
|
|
@ -1 +1 @@
|
|||
export default 'c'
|
||||
export default "c";
|
||||
|
|
|
@ -1,226 +1,206 @@
|
|||
it('should be able to use eager mode', function () {
|
||||
it("should be able to use eager mode", function () {
|
||||
function load(name) {
|
||||
return import(/* webpackMode: "eager" */ './dir1/' + name)
|
||||
return import(/* webpackMode: "eager" */ "./dir1/" + name);
|
||||
}
|
||||
return testChunkLoading(load, true, true)
|
||||
})
|
||||
return testChunkLoading(load, true, true);
|
||||
});
|
||||
|
||||
it('should be able to use lazy-once mode', function () {
|
||||
it("should be able to use lazy-once mode", function () {
|
||||
function load(name) {
|
||||
return import(/* webpackMode: "lazy-once" */ './dir2/' + name)
|
||||
return import(/* webpackMode: "lazy-once" */ "./dir2/" + name);
|
||||
}
|
||||
return testChunkLoading(load, false, true)
|
||||
})
|
||||
return testChunkLoading(load, false, true);
|
||||
});
|
||||
|
||||
it('should be able to use lazy-once mode with name', function () {
|
||||
it("should be able to use lazy-once mode with name", function () {
|
||||
function load(name) {
|
||||
return import(
|
||||
/* webpackMode: "lazy-once", webpackChunkName: "name-lazy-once" */ './dir3/' +
|
||||
name
|
||||
)
|
||||
return import(/* webpackMode: "lazy-once", webpackChunkName: "name-lazy-once" */ "./dir3/" + name);
|
||||
}
|
||||
return testChunkLoading(load, false, true)
|
||||
})
|
||||
return testChunkLoading(load, false, true);
|
||||
});
|
||||
|
||||
it('should be able to use lazy mode', function () {
|
||||
it("should be able to use lazy mode", function () {
|
||||
function load(name) {
|
||||
return import(/* webpackMode: "lazy" */ './dir4/' + name)
|
||||
return import(/* webpackMode: "lazy" */ "./dir4/" + name);
|
||||
}
|
||||
return testChunkLoading(load, false, false)
|
||||
})
|
||||
return testChunkLoading(load, false, false);
|
||||
});
|
||||
|
||||
it('should be able to use lazy mode with name', function () {
|
||||
it("should be able to use lazy mode with name", function () {
|
||||
function load(name) {
|
||||
return import(
|
||||
/* webpackMode: "lazy", webpackChunkName: "name-lazy" */ './dir5/' + name
|
||||
)
|
||||
return import(/* webpackMode: "lazy", webpackChunkName: "name-lazy" */ "./dir5/" + name);
|
||||
}
|
||||
return testChunkLoading(load, false, false)
|
||||
})
|
||||
return testChunkLoading(load, false, false);
|
||||
});
|
||||
|
||||
it('should be able to use lazy mode with name and placeholder', function () {
|
||||
it("should be able to use lazy mode with name and placeholder", function () {
|
||||
function load(name) {
|
||||
return import(
|
||||
/* webpackMode: "lazy", webpackChunkName: "name-lazy-[request]" */ './dir6/' +
|
||||
name
|
||||
)
|
||||
return import(/* webpackMode: "lazy", webpackChunkName: "name-lazy-[request]" */ "./dir6/" + name);
|
||||
}
|
||||
return testChunkLoading(load, false, false)
|
||||
})
|
||||
return testChunkLoading(load, false, false);
|
||||
});
|
||||
|
||||
it('should be able to combine chunks by name', function () {
|
||||
it("should be able to combine chunks by name", function () {
|
||||
function load(name) {
|
||||
switch (name) {
|
||||
case 'a':
|
||||
return import(/* webpackMode: "eager" */ './dir7/a')
|
||||
case 'b':
|
||||
return import(/* webpackChunkName: "name-3" */ './dir7/b')
|
||||
case 'c':
|
||||
return import(/* webpackChunkName: "name-3" */ './dir7/c')
|
||||
case 'd':
|
||||
return import(/* webpackChunkName: "name-3" */ './dir7/d')
|
||||
case "a":
|
||||
return import(/* webpackMode: "eager" */ "./dir7/a");
|
||||
case "b":
|
||||
return import(/* webpackChunkName: "name-3" */ "./dir7/b");
|
||||
case "c":
|
||||
return import(/* webpackChunkName: "name-3" */ "./dir7/c");
|
||||
case "d":
|
||||
return import(/* webpackChunkName: "name-3" */ "./dir7/d");
|
||||
default:
|
||||
throw new Error('Unexpected test data')
|
||||
throw new Error("Unexpected test data");
|
||||
}
|
||||
}
|
||||
return testChunkLoading(load, false, true)
|
||||
})
|
||||
return testChunkLoading(load, false, true);
|
||||
});
|
||||
|
||||
it('should be able to use weak mode', function () {
|
||||
it("should be able to use weak mode", function () {
|
||||
function load(name) {
|
||||
return import(/* webpackMode: "weak" */ './dir8/' + name)
|
||||
return import(/* webpackMode: "weak" */ "./dir8/" + name);
|
||||
}
|
||||
require('./dir8/a') // chunks served manually by the user
|
||||
require('./dir8/b')
|
||||
require('./dir8/c')
|
||||
return testChunkLoading(load, true, true)
|
||||
})
|
||||
require("./dir8/a"); // chunks served manually by the user
|
||||
require("./dir8/b");
|
||||
require("./dir8/c");
|
||||
return testChunkLoading(load, true, true);
|
||||
});
|
||||
|
||||
it('should be able to use weak mode (without context)', function () {
|
||||
it("should be able to use weak mode (without context)", function () {
|
||||
function load(name) {
|
||||
switch (name) {
|
||||
case 'a':
|
||||
return import(/* webpackMode: "weak" */ './dir9/a')
|
||||
case 'b':
|
||||
return import(/* webpackMode: "weak" */ './dir9/b')
|
||||
case 'c':
|
||||
return import(/* webpackMode: "weak" */ './dir9/c')
|
||||
case "a":
|
||||
return import(/* webpackMode: "weak" */ "./dir9/a");
|
||||
case "b":
|
||||
return import(/* webpackMode: "weak" */ "./dir9/b");
|
||||
case "c":
|
||||
return import(/* webpackMode: "weak" */ "./dir9/c");
|
||||
default:
|
||||
throw new Error('Unexpected test data')
|
||||
throw new Error("Unexpected test data");
|
||||
}
|
||||
}
|
||||
require('./dir9/a') // chunks served manually by the user
|
||||
require('./dir9/b')
|
||||
require('./dir9/c')
|
||||
return testChunkLoading(load, true, true)
|
||||
})
|
||||
require("./dir9/a"); // chunks served manually by the user
|
||||
require("./dir9/b");
|
||||
require("./dir9/c");
|
||||
return testChunkLoading(load, true, true);
|
||||
});
|
||||
|
||||
it('should not find module when mode is weak and chunk not served elsewhere', function () {
|
||||
var name = 'a'
|
||||
return import(/* webpackMode: "weak" */ './dir10/' + name).catch(function (
|
||||
e,
|
||||
) {
|
||||
it("should not find module when mode is weak and chunk not served elsewhere", function () {
|
||||
var name = "a";
|
||||
return import(/* webpackMode: "weak" */ "./dir10/" + name).catch(function (e) {
|
||||
expect(e).toMatchObject({
|
||||
message: /not available/,
|
||||
code: /MODULE_NOT_FOUND/,
|
||||
})
|
||||
})
|
||||
})
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
it('should not find module when mode is weak and chunk not served elsewhere (without context)', function () {
|
||||
return import(/* webpackMode: "weak" */ './dir11/a').catch(function (e) {
|
||||
it("should not find module when mode is weak and chunk not served elsewhere (without context)", function () {
|
||||
return import(/* webpackMode: "weak" */ "./dir11/a").catch(function (e) {
|
||||
expect(e).toMatchObject({
|
||||
message: /not available/,
|
||||
code: /MODULE_NOT_FOUND/,
|
||||
})
|
||||
})
|
||||
})
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
if (process.env.NODE_ENV === 'production') {
|
||||
it('should contain only one export from webpackExports from module', function () {
|
||||
return import(/* webpackExports: "usedExports" */ './dir12/a?1').then(
|
||||
(module) => {
|
||||
expect(module.usedExports).toEqual(['usedExports'])
|
||||
},
|
||||
)
|
||||
})
|
||||
if (process.env.NODE_ENV === "production") {
|
||||
it("should contain only one export from webpackExports from module", function () {
|
||||
return import(/* webpackExports: "usedExports" */ "./dir12/a?1").then((module) => {
|
||||
expect(module.usedExports).toEqual(["usedExports"]);
|
||||
});
|
||||
});
|
||||
|
||||
it('should contain only webpackExports from module', function () {
|
||||
return import(
|
||||
/* webpackExports: ["a", "usedExports", "b"] */ './dir12/a?2'
|
||||
).then((module) => {
|
||||
expect(module.usedExports).toEqual(['a', 'b', 'usedExports'])
|
||||
})
|
||||
})
|
||||
it("should contain only webpackExports from module", function () {
|
||||
return import(/* webpackExports: ["a", "usedExports", "b"] */ "./dir12/a?2").then((module) => {
|
||||
expect(module.usedExports).toEqual(["a", "b", "usedExports"]);
|
||||
});
|
||||
});
|
||||
|
||||
it('should contain only webpackExports from module in eager mode', function () {
|
||||
it("should contain only webpackExports from module in eager mode", function () {
|
||||
return import(
|
||||
/*
|
||||
webpackMode: "eager",
|
||||
webpackExports: ["a", "usedExports", "b"]
|
||||
*/ './dir12/a?3'
|
||||
*/ "./dir12/a?3"
|
||||
).then((module) => {
|
||||
expect(module.usedExports).toEqual(['a', 'b', 'usedExports'])
|
||||
})
|
||||
})
|
||||
expect(module.usedExports).toEqual(["a", "b", "usedExports"]);
|
||||
});
|
||||
});
|
||||
|
||||
it('should contain webpackExports from module in weak mode', function () {
|
||||
require.resolve('./dir12/a?4')
|
||||
it("should contain webpackExports from module in weak mode", function () {
|
||||
require.resolve("./dir12/a?4");
|
||||
return import(
|
||||
/*
|
||||
webpackMode: "weak",
|
||||
webpackExports: ["a", "usedExports", "b"]
|
||||
*/ './dir12/a?4'
|
||||
*/ "./dir12/a?4"
|
||||
).then((module) => {
|
||||
expect(module.usedExports).toEqual(['a', 'b', 'usedExports'])
|
||||
})
|
||||
})
|
||||
expect(module.usedExports).toEqual(["a", "b", "usedExports"]);
|
||||
});
|
||||
});
|
||||
|
||||
it('should not mangle webpackExports from module', function () {
|
||||
return import(/* webpackExports: "longnameforexport" */ './dir12/a?5').then(
|
||||
(module) => {
|
||||
expect(module).toHaveProperty('longnameforexport')
|
||||
},
|
||||
)
|
||||
})
|
||||
it("should not mangle webpackExports from module", function () {
|
||||
return import(/* webpackExports: "longnameforexport" */ "./dir12/a?5").then((module) => {
|
||||
expect(module).toHaveProperty("longnameforexport");
|
||||
});
|
||||
});
|
||||
|
||||
it('should not mangle default webpackExports from module', function () {
|
||||
return import(/* webpackExports: "default" */ './dir12/a?6').then(
|
||||
(module) => {
|
||||
expect(module).toHaveProperty('default')
|
||||
},
|
||||
)
|
||||
})
|
||||
it("should not mangle default webpackExports from module", function () {
|
||||
return import(/* webpackExports: "default" */ "./dir12/a?6").then((module) => {
|
||||
expect(module).toHaveProperty("default");
|
||||
});
|
||||
});
|
||||
|
||||
it('should contain only webpackExports from module in context mode', function () {
|
||||
const x = 'b'
|
||||
return import(/* webpackExports: "usedExports" */ `./dir13/${x}`).then(
|
||||
(module) => {
|
||||
expect(module.usedExports).toEqual(['usedExports'])
|
||||
},
|
||||
)
|
||||
})
|
||||
it("should contain only webpackExports from module in context mode", function () {
|
||||
const x = "b";
|
||||
return import(/* webpackExports: "usedExports" */ `./dir13/${x}`).then((module) => {
|
||||
expect(module.usedExports).toEqual(["usedExports"]);
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
function testChunkLoading(load, expectedSyncInitial, expectedSyncRequested) {
|
||||
var sync = false
|
||||
var syncInitial = true
|
||||
var p = Promise.all([load('a'), load('b')]).then(function () {
|
||||
expect(syncInitial).toBe(expectedSyncInitial)
|
||||
sync = true
|
||||
var sync = false;
|
||||
var syncInitial = true;
|
||||
var p = Promise.all([load("a"), load("b")]).then(function () {
|
||||
expect(syncInitial).toBe(expectedSyncInitial);
|
||||
sync = true;
|
||||
var p = Promise.all([
|
||||
load('a').then(function (a) {
|
||||
load("a").then(function (a) {
|
||||
expect(a).toEqual(
|
||||
nsObj({
|
||||
default: 'a',
|
||||
}),
|
||||
)
|
||||
expect(sync).toBe(true)
|
||||
default: "a",
|
||||
})
|
||||
);
|
||||
expect(sync).toBe(true);
|
||||
}),
|
||||
load('c').then(function (c) {
|
||||
load("c").then(function (c) {
|
||||
expect(c).toEqual(
|
||||
nsObj({
|
||||
default: 'c',
|
||||
}),
|
||||
)
|
||||
expect(sync).toBe(expectedSyncRequested)
|
||||
default: "c",
|
||||
})
|
||||
);
|
||||
expect(sync).toBe(expectedSyncRequested);
|
||||
}),
|
||||
])
|
||||
]);
|
||||
Promise.resolve()
|
||||
.then(function () {})
|
||||
.then(function () {})
|
||||
.then(function () {})
|
||||
.then(function () {
|
||||
sync = false
|
||||
})
|
||||
return p
|
||||
})
|
||||
sync = false;
|
||||
});
|
||||
return p;
|
||||
});
|
||||
Promise.resolve()
|
||||
.then(function () {})
|
||||
.then(function () {})
|
||||
.then(function () {})
|
||||
.then(function () {
|
||||
syncInitial = false
|
||||
})
|
||||
return p
|
||||
syncInitial = false;
|
||||
});
|
||||
return p;
|
||||
}
|
||||
|
|
|
@ -1 +1 @@
|
|||
module.exports = 1
|
||||
module.exports = 1;
|
||||
|
|
|
@ -1 +1 @@
|
|||
module.exports = 3
|
||||
module.exports = 3;
|
||||
|
|
|
@ -1 +1 @@
|
|||
module.exports = 2
|
||||
module.exports = 2;
|
||||
|
|
|
@ -1,26 +1,26 @@
|
|||
it('should be able to use expressions in import (directory)', function (done) {
|
||||
it("should be able to use expressions in import (directory)", function (done) {
|
||||
function load(name, expected, callback) {
|
||||
import('./dir/' + name + '/file.js')
|
||||
import("./dir/" + name + "/file.js")
|
||||
.then(function (result) {
|
||||
expect(result).toEqual(
|
||||
nsObj({
|
||||
default: expected,
|
||||
}),
|
||||
)
|
||||
callback()
|
||||
})
|
||||
);
|
||||
callback();
|
||||
})
|
||||
.catch(function (err) {
|
||||
done(err)
|
||||
})
|
||||
done(err);
|
||||
});
|
||||
}
|
||||
if (Math.random() < 0) require('./dir/three/file')
|
||||
load('one', 1, function () {
|
||||
load('two', 2, function () {
|
||||
load('three', 3, function () {
|
||||
load('two', 2, function () {
|
||||
done()
|
||||
})
|
||||
})
|
||||
})
|
||||
})
|
||||
})
|
||||
if (Math.random() < 0) require("./dir/three/file");
|
||||
load("one", 1, function () {
|
||||
load("two", 2, function () {
|
||||
load("three", 3, function () {
|
||||
load("two", 2, function () {
|
||||
done();
|
||||
});
|
||||
});
|
||||
});
|
||||
});
|
||||
});
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
import x from './module'
|
||||
import x from "./module";
|
||||
|
||||
it('should export the same binding', () => {
|
||||
return import('./module').then((ns) => {
|
||||
expect(x).toBe(ns.default)
|
||||
})
|
||||
})
|
||||
it("should export the same binding", () => {
|
||||
return import("./module").then((ns) => {
|
||||
expect(x).toBe(ns.default);
|
||||
});
|
||||
});
|
||||
|
|
|
@ -1 +1 @@
|
|||
export default {}
|
||||
export default {};
|
||||
|
|
|
@ -1,177 +1,169 @@
|
|||
it('should handle named chunks', function (done) {
|
||||
var sync = false
|
||||
it("should handle named chunks", function (done) {
|
||||
var sync = false;
|
||||
require.ensure(
|
||||
[],
|
||||
function (require) {
|
||||
require('./empty?a')
|
||||
require('./empty?b')
|
||||
testLoad()
|
||||
sync = true
|
||||
require("./empty?a");
|
||||
require("./empty?b");
|
||||
testLoad();
|
||||
sync = true;
|
||||
process.nextTick(function () {
|
||||
sync = false
|
||||
})
|
||||
sync = false;
|
||||
});
|
||||
},
|
||||
'named-chunk',
|
||||
)
|
||||
"named-chunk"
|
||||
);
|
||||
function testLoad() {
|
||||
require.ensure(
|
||||
[],
|
||||
function (require) {
|
||||
require('./empty?c')
|
||||
require('./empty?d')
|
||||
expect(sync).toBeTruthy()
|
||||
done()
|
||||
require("./empty?c");
|
||||
require("./empty?d");
|
||||
expect(sync).toBeTruthy();
|
||||
done();
|
||||
},
|
||||
'named-chunk',
|
||||
)
|
||||
"named-chunk"
|
||||
);
|
||||
}
|
||||
})
|
||||
});
|
||||
|
||||
it('should handle empty named chunks', function (done) {
|
||||
var sync = false
|
||||
it("should handle empty named chunks", function (done) {
|
||||
var sync = false;
|
||||
require.ensure(
|
||||
[],
|
||||
function (require) {
|
||||
expect(sync).toBeTruthy()
|
||||
expect(sync).toBeTruthy();
|
||||
},
|
||||
'empty-named-chunk',
|
||||
)
|
||||
"empty-named-chunk"
|
||||
);
|
||||
require.ensure(
|
||||
[],
|
||||
function (require) {
|
||||
expect(sync).toBeTruthy()
|
||||
done()
|
||||
expect(sync).toBeTruthy();
|
||||
done();
|
||||
},
|
||||
'empty-named-chunk',
|
||||
)
|
||||
sync = true
|
||||
"empty-named-chunk"
|
||||
);
|
||||
sync = true;
|
||||
setImmediate(function () {
|
||||
sync = false
|
||||
})
|
||||
})
|
||||
sync = false;
|
||||
});
|
||||
});
|
||||
|
||||
it('should handle named chunks when there is an error callback', function (done) {
|
||||
var sync = false
|
||||
it("should handle named chunks when there is an error callback", function (done) {
|
||||
var sync = false;
|
||||
require.ensure(
|
||||
[],
|
||||
function (require) {
|
||||
require('./empty?e')
|
||||
require('./empty?f')
|
||||
testLoad()
|
||||
sync = true
|
||||
require("./empty?e");
|
||||
require("./empty?f");
|
||||
testLoad();
|
||||
sync = true;
|
||||
process.nextTick(function () {
|
||||
sync = false
|
||||
})
|
||||
sync = false;
|
||||
});
|
||||
},
|
||||
function (error) {},
|
||||
'named-chunk-for-error-callback',
|
||||
)
|
||||
"named-chunk-for-error-callback"
|
||||
);
|
||||
function testLoad() {
|
||||
require.ensure(
|
||||
[],
|
||||
function (require) {
|
||||
require('./empty?g')
|
||||
require('./empty?h')
|
||||
expect(sync).toBeTruthy()
|
||||
done()
|
||||
require("./empty?g");
|
||||
require("./empty?h");
|
||||
expect(sync).toBeTruthy();
|
||||
done();
|
||||
},
|
||||
function (error) {},
|
||||
'named-chunk-for-error-callback',
|
||||
)
|
||||
"named-chunk-for-error-callback"
|
||||
);
|
||||
}
|
||||
})
|
||||
});
|
||||
|
||||
it('should handle empty named chunks when there is an error callback', function (done) {
|
||||
var sync = false
|
||||
it("should handle empty named chunks when there is an error callback", function (done) {
|
||||
var sync = false;
|
||||
require.ensure(
|
||||
[],
|
||||
function (require) {
|
||||
expect(sync).toBeTruthy()
|
||||
expect(sync).toBeTruthy();
|
||||
},
|
||||
function (error) {},
|
||||
'empty-named-chunk-for-error-callback',
|
||||
)
|
||||
"empty-named-chunk-for-error-callback"
|
||||
);
|
||||
require.ensure(
|
||||
[],
|
||||
function (require) {
|
||||
expect(sync).toBeTruthy()
|
||||
done()
|
||||
expect(sync).toBeTruthy();
|
||||
done();
|
||||
},
|
||||
function (error) {},
|
||||
'empty-named-chunk-for-error-callback',
|
||||
)
|
||||
sync = true
|
||||
"empty-named-chunk-for-error-callback"
|
||||
);
|
||||
sync = true;
|
||||
setImmediate(function () {
|
||||
sync = false
|
||||
})
|
||||
})
|
||||
sync = false;
|
||||
});
|
||||
});
|
||||
|
||||
it('should be able to use named chunks in import()', function (done) {
|
||||
var sync = false
|
||||
import(
|
||||
'./empty?import1-in-chunk1' /* webpackChunkName: "import-named-chunk-1" */
|
||||
).then(function (result) {
|
||||
var i = 0
|
||||
import(
|
||||
'./empty?import2-in-chunk1' /* webpackChunkName: "import-named-chunk-1" */
|
||||
)
|
||||
it("should be able to use named chunks in import()", function (done) {
|
||||
var sync = false;
|
||||
import("./empty?import1-in-chunk1" /* webpackChunkName: "import-named-chunk-1" */).then(function (result) {
|
||||
var i = 0;
|
||||
import("./empty?import2-in-chunk1" /* webpackChunkName: "import-named-chunk-1" */)
|
||||
.then(function (result) {
|
||||
expect(sync).toBeTruthy()
|
||||
if (i++ > 0) done()
|
||||
expect(sync).toBeTruthy();
|
||||
if (i++ > 0) done();
|
||||
})
|
||||
.catch(function (err) {
|
||||
done(err)
|
||||
})
|
||||
import(
|
||||
'./empty?import3-in-chunk2' /* webpackChunkName: "import-named-chunk-2" */
|
||||
)
|
||||
done(err);
|
||||
});
|
||||
import("./empty?import3-in-chunk2" /* webpackChunkName: "import-named-chunk-2" */)
|
||||
.then(function (result) {
|
||||
expect(sync).toBeFalsy()
|
||||
if (i++ > 0) done()
|
||||
expect(sync).toBeFalsy();
|
||||
if (i++ > 0) done();
|
||||
})
|
||||
.catch(function (err) {
|
||||
done(err)
|
||||
})
|
||||
sync = true
|
||||
done(err);
|
||||
});
|
||||
sync = true;
|
||||
Promise.resolve()
|
||||
.then(function () {})
|
||||
.then(function () {})
|
||||
.then(function () {
|
||||
sync = false
|
||||
})
|
||||
})
|
||||
})
|
||||
sync = false;
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
it('should be able to use named chunk in context import()', function (done) {
|
||||
it("should be able to use named chunk in context import()", function (done) {
|
||||
// cspell:ignore mpty
|
||||
var mpty = 'mpty'
|
||||
var sync = false
|
||||
import('./e' + mpty + '2' /* webpackChunkName: "context-named-chunk" */).then(
|
||||
function (result) {
|
||||
var i = 0
|
||||
import('./e' + mpty + '3' /* webpackChunkName: "context-named-chunk" */)
|
||||
.then(function (result) {
|
||||
expect(sync).toBeTruthy()
|
||||
if (i++ > 0) done()
|
||||
})
|
||||
.catch(function (err) {
|
||||
done(err)
|
||||
})
|
||||
import('./e' + mpty + '4' /* webpackChunkName: "context-named-chunk-2" */)
|
||||
.then(function (result) {
|
||||
expect(sync).toBeFalsy()
|
||||
if (i++ > 0) done()
|
||||
})
|
||||
.catch(function (err) {
|
||||
done(err)
|
||||
})
|
||||
sync = true
|
||||
Promise.resolve()
|
||||
.then(function () {})
|
||||
.then(function () {})
|
||||
.then(function () {
|
||||
sync = false
|
||||
})
|
||||
},
|
||||
)
|
||||
})
|
||||
var mpty = "mpty";
|
||||
var sync = false;
|
||||
import("./e" + mpty + "2" /* webpackChunkName: "context-named-chunk" */).then(function (result) {
|
||||
var i = 0;
|
||||
import("./e" + mpty + "3" /* webpackChunkName: "context-named-chunk" */)
|
||||
.then(function (result) {
|
||||
expect(sync).toBeTruthy();
|
||||
if (i++ > 0) done();
|
||||
})
|
||||
.catch(function (err) {
|
||||
done(err);
|
||||
});
|
||||
import("./e" + mpty + "4" /* webpackChunkName: "context-named-chunk-2" */)
|
||||
.then(function (result) {
|
||||
expect(sync).toBeFalsy();
|
||||
if (i++ > 0) done();
|
||||
})
|
||||
.catch(function (err) {
|
||||
done(err);
|
||||
});
|
||||
sync = true;
|
||||
Promise.resolve()
|
||||
.then(function () {})
|
||||
.then(function () {})
|
||||
.then(function () {
|
||||
sync = false;
|
||||
});
|
||||
});
|
||||
});
|
||||
|
|
|
@ -1 +1 @@
|
|||
module.exports = 42
|
||||
module.exports = 42;
|
||||
|
|
|
@ -1,13 +1,13 @@
|
|||
it('should include a chunk nested in an empty chunk', (done) => {
|
||||
require.ensure(['./a'], () => {
|
||||
it("should include a chunk nested in an empty chunk", (done) => {
|
||||
require.ensure(["./a"], () => {
|
||||
require.ensure([], () => {
|
||||
require.ensure(['./a'], () => {
|
||||
require.ensure(["./a"], () => {
|
||||
require.ensure([], () => {
|
||||
const b = require('./b')
|
||||
expect(b).toBe(42)
|
||||
done()
|
||||
})
|
||||
})
|
||||
})
|
||||
})
|
||||
})
|
||||
const b = require("./b");
|
||||
expect(b).toBe(42);
|
||||
done();
|
||||
});
|
||||
});
|
||||
});
|
||||
});
|
||||
});
|
||||
|
|
|
@ -1,49 +1,49 @@
|
|||
it('should handle bound function expressions', function (done) {
|
||||
it("should handle bound function expressions", function (done) {
|
||||
require.ensure(
|
||||
[],
|
||||
function (require) {
|
||||
expect(this).toEqual({ test: true })
|
||||
require('./empty?test')
|
||||
expect(process.nextTick).toBeTypeOf('function') // check if injection still works
|
||||
expect(this).toEqual({ test: true });
|
||||
require("./empty?test");
|
||||
expect(process.nextTick).toBeTypeOf("function"); // check if injection still works
|
||||
require.ensure(
|
||||
[],
|
||||
function (require) {
|
||||
expect(this).toEqual({ test: true })
|
||||
done()
|
||||
}.bind(this),
|
||||
)
|
||||
}.bind({ test: true }),
|
||||
)
|
||||
})
|
||||
expect(this).toEqual({ test: true });
|
||||
done();
|
||||
}.bind(this)
|
||||
);
|
||||
}.bind({ test: true })
|
||||
);
|
||||
});
|
||||
|
||||
it('should handle require.ensure without function expression', function (done) {
|
||||
it("should handle require.ensure without function expression", function (done) {
|
||||
function f() {
|
||||
done()
|
||||
done();
|
||||
}
|
||||
require.ensure([], f)
|
||||
})
|
||||
require.ensure([], f);
|
||||
});
|
||||
|
||||
it("should parse expression in require.ensure, which isn't a function expression", function (done) {
|
||||
require.ensure(
|
||||
[],
|
||||
(function () {
|
||||
expect(require('./empty?require.ensure:test')).toEqual({})
|
||||
expect(require("./empty?require.ensure:test")).toEqual({});
|
||||
return function f() {
|
||||
done()
|
||||
}
|
||||
})(),
|
||||
)
|
||||
})
|
||||
done();
|
||||
};
|
||||
})()
|
||||
);
|
||||
});
|
||||
|
||||
it('should accept an already included module', function (done) {
|
||||
if (Math.random() < 0) require('./require.include')
|
||||
var value = null
|
||||
it("should accept an already included module", function (done) {
|
||||
if (Math.random() < 0) require("./require.include");
|
||||
var value = null;
|
||||
require.ensure([], function (require) {
|
||||
value = require('./require.include')
|
||||
})
|
||||
value = require("./require.include");
|
||||
});
|
||||
setImmediate(function () {
|
||||
expect(value).toBe('require.include')
|
||||
expect(value).toBe('require.include')
|
||||
done()
|
||||
})
|
||||
})
|
||||
expect(value).toBe("require.include");
|
||||
expect(value).toBe("require.include");
|
||||
done();
|
||||
});
|
||||
});
|
||||
|
|
|
@ -1 +1 @@
|
|||
module.exports = 'require.include'
|
||||
module.exports = "require.include";
|
||||
|
|
|
@ -1 +1 @@
|
|||
module.exports = 'a'
|
||||
module.exports = "a";
|
||||
|
|
|
@ -1,3 +1,3 @@
|
|||
require.ensure(['./acircular2'], function (require) {
|
||||
require('./acircular2')
|
||||
})
|
||||
require.ensure(["./acircular2"], function (require) {
|
||||
require("./acircular2");
|
||||
});
|
||||
|
|
|
@ -1,3 +1,3 @@
|
|||
require.ensure(['./acircular'], function (require) {
|
||||
require('./acircular')
|
||||
})
|
||||
require.ensure(["./acircular"], function (require) {
|
||||
require("./acircular");
|
||||
});
|
||||
|
|
|
@ -1 +1 @@
|
|||
module.exports = require('./a')
|
||||
module.exports = require("./a");
|
||||
|
|
|
@ -1,3 +1,3 @@
|
|||
require.ensure(['./a'], function (require) {
|
||||
expect(require('./a')).toBe('a')
|
||||
})
|
||||
require.ensure(["./a"], function (require) {
|
||||
expect(require("./a")).toBe("a");
|
||||
});
|
||||
|
|
|
@ -1,3 +1,3 @@
|
|||
require.ensure(['./b'], function (require) {
|
||||
expect(require('./b')).toBe('a')
|
||||
})
|
||||
require.ensure(["./b"], function (require) {
|
||||
expect(require("./b")).toBe("a");
|
||||
});
|
||||
|
|
|
@ -1,54 +1,54 @@
|
|||
/* globals it */
|
||||
it('should handle duplicate chunks', function (done) {
|
||||
it("should handle duplicate chunks", function (done) {
|
||||
var firstOne = false,
|
||||
secondOne = false
|
||||
secondOne = false;
|
||||
require.ensure([], function (require) {
|
||||
require('./acircular')
|
||||
require('./duplicate')
|
||||
require('./duplicate2')
|
||||
firstOne = true
|
||||
if (secondOne) done()
|
||||
})
|
||||
require("./acircular");
|
||||
require("./duplicate");
|
||||
require("./duplicate2");
|
||||
firstOne = true;
|
||||
if (secondOne) done();
|
||||
});
|
||||
require.ensure([], function (require) {
|
||||
require('./acircular2')
|
||||
require('./duplicate')
|
||||
require('./duplicate2')
|
||||
secondOne = true
|
||||
if (firstOne) done()
|
||||
})
|
||||
})
|
||||
require("./acircular2");
|
||||
require("./duplicate");
|
||||
require("./duplicate2");
|
||||
secondOne = true;
|
||||
if (firstOne) done();
|
||||
});
|
||||
});
|
||||
|
||||
it('should not load a chunk which is included in a already loaded one', function (done) {
|
||||
var asyncFlag = false
|
||||
require.ensure(['./empty?x', './empty?y', './empty?z'], function (require) {
|
||||
it("should not load a chunk which is included in a already loaded one", function (done) {
|
||||
var asyncFlag = false;
|
||||
require.ensure(["./empty?x", "./empty?y", "./empty?z"], function (require) {
|
||||
try {
|
||||
expect(asyncFlag).toBe(true)
|
||||
loadChunk()
|
||||
expect(asyncFlag).toBe(true);
|
||||
loadChunk();
|
||||
} catch (e) {
|
||||
done(e)
|
||||
done(e);
|
||||
}
|
||||
})
|
||||
});
|
||||
Promise.resolve()
|
||||
.then(function () {})
|
||||
.then(function () {})
|
||||
.then(function () {
|
||||
asyncFlag = true
|
||||
})
|
||||
asyncFlag = true;
|
||||
});
|
||||
function loadChunk() {
|
||||
var sync = true
|
||||
require.ensure(['./empty?x', './empty?y'], function (require) {
|
||||
var sync = true;
|
||||
require.ensure(["./empty?x", "./empty?y"], function (require) {
|
||||
try {
|
||||
expect(sync).toBe(true)
|
||||
done()
|
||||
expect(sync).toBe(true);
|
||||
done();
|
||||
} catch (e) {
|
||||
done(e)
|
||||
done(e);
|
||||
}
|
||||
})
|
||||
});
|
||||
Promise.resolve()
|
||||
.then(function () {})
|
||||
.then(function () {})
|
||||
.then(function () {
|
||||
sync = false
|
||||
})
|
||||
sync = false;
|
||||
});
|
||||
}
|
||||
})
|
||||
});
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
module.exports = function (config) {
|
||||
// This test can't run in development mode as it depends on the flagIncludedChunks optimization
|
||||
return config.mode !== 'development'
|
||||
}
|
||||
return config.mode !== "development";
|
||||
};
|
||||
|
|
|
@ -1,12 +1,12 @@
|
|||
it('should handle var injection in require.ensure with error callback', function (done) {
|
||||
it("should handle var injection in require.ensure with error callback", function (done) {
|
||||
require.ensure(
|
||||
[],
|
||||
function (require) {
|
||||
require('./empty')
|
||||
var x = module.x
|
||||
done()
|
||||
require("./empty");
|
||||
var x = module.x;
|
||||
done();
|
||||
},
|
||||
function (error) {},
|
||||
'chunk-with-var-inject',
|
||||
)
|
||||
})
|
||||
"chunk-with-var-inject"
|
||||
);
|
||||
});
|
||||
|
|
|
@ -1,24 +1,24 @@
|
|||
it('should not include a module with a weak dependency using context', function () {
|
||||
var fileA = 'a'
|
||||
var fileB = 'b'
|
||||
var fileC = 'c'
|
||||
it("should not include a module with a weak dependency using context", function () {
|
||||
var fileA = "a";
|
||||
var fileB = "b";
|
||||
var fileC = "c";
|
||||
|
||||
var resolveWeakA = require.resolveWeak('./' + fileA)
|
||||
var resolveWeakB = require.resolveWeak('./' + fileB)
|
||||
var resolveWeakC = require.resolveWeak('./' + fileC)
|
||||
var resolveWeakA = require.resolveWeak("./" + fileA);
|
||||
var resolveWeakB = require.resolveWeak("./" + fileB);
|
||||
var resolveWeakC = require.resolveWeak("./" + fileC);
|
||||
|
||||
var a = !!__webpack_modules__[resolveWeakA]
|
||||
var b = !!__webpack_modules__[resolveWeakB]
|
||||
var c = !!__webpack_modules__[resolveWeakC]
|
||||
var a = !!__webpack_modules__[resolveWeakA];
|
||||
var b = !!__webpack_modules__[resolveWeakB];
|
||||
var c = !!__webpack_modules__[resolveWeakC];
|
||||
|
||||
require(['./b'])
|
||||
require('./c')
|
||||
require(["./b"]);
|
||||
require("./c");
|
||||
|
||||
expect(resolveWeakA).toBeDefined()
|
||||
expect(resolveWeakB).toBeDefined()
|
||||
expect(resolveWeakC).toBeDefined()
|
||||
expect(resolveWeakA).toBeDefined();
|
||||
expect(resolveWeakB).toBeDefined();
|
||||
expect(resolveWeakC).toBeDefined();
|
||||
|
||||
expect(a).toBe(false)
|
||||
expect(b).toBe(false)
|
||||
expect(c).toBe(true)
|
||||
})
|
||||
expect(a).toBe(false);
|
||||
expect(b).toBe(false);
|
||||
expect(c).toBe(true);
|
||||
});
|
||||
|
|
|
@ -1,13 +1,13 @@
|
|||
it('should not include a module with a weak dependency', function () {
|
||||
var a = !!__webpack_modules__[require.resolveWeak('./a')]
|
||||
var b = !!__webpack_modules__[require.resolve('./b')]
|
||||
var c = !!__webpack_modules__[require.resolveWeak('./c')]
|
||||
var d = !!__webpack_modules__[require.resolveWeak('./d')]
|
||||
require(['./c'])
|
||||
require('./d')
|
||||
it("should not include a module with a weak dependency", function () {
|
||||
var a = !!__webpack_modules__[require.resolveWeak("./a")];
|
||||
var b = !!__webpack_modules__[require.resolve("./b")];
|
||||
var c = !!__webpack_modules__[require.resolveWeak("./c")];
|
||||
var d = !!__webpack_modules__[require.resolveWeak("./d")];
|
||||
require(["./c"]);
|
||||
require("./d");
|
||||
|
||||
expect(a).toBe(false)
|
||||
expect(b).toBe(true)
|
||||
expect(c).toBe(false)
|
||||
expect(d).toBe(true)
|
||||
})
|
||||
expect(a).toBe(false);
|
||||
expect(b).toBe(true);
|
||||
expect(c).toBe(false);
|
||||
expect(d).toBe(true);
|
||||
});
|
||||
|
|
|
@ -1,16 +1,16 @@
|
|||
it('should handle circular chunks correctly', function (done) {
|
||||
import(/* webpackChunkName: "a" */ './module-a')
|
||||
it("should handle circular chunks correctly", function (done) {
|
||||
import(/* webpackChunkName: "a" */ "./module-a")
|
||||
.then(function (result) {
|
||||
return result.default()
|
||||
return result.default();
|
||||
})
|
||||
.then(function (result2) {
|
||||
expect(result2.default()).toBe('x')
|
||||
done()
|
||||
expect(result2.default()).toBe("x");
|
||||
done();
|
||||
})
|
||||
.catch(function (e) {
|
||||
done(e)
|
||||
})
|
||||
done(e);
|
||||
});
|
||||
const couldBe = function () {
|
||||
return import(/* webpackChunkName: "b" */ './module-b')
|
||||
}
|
||||
})
|
||||
return import(/* webpackChunkName: "b" */ "./module-b");
|
||||
};
|
||||
});
|
||||
|
|
|
@ -1,3 +1,3 @@
|
|||
export default function () {
|
||||
return import(/* webpackChunkName: "c" */ './module-c')
|
||||
return import(/* webpackChunkName: "c" */ "./module-c");
|
||||
}
|
||||
|
|
|
@ -1 +1 @@
|
|||
export default 'a2'
|
||||
export default "a2";
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
import './module-x'
|
||||
import "./module-x";
|
||||
|
||||
export default function () {
|
||||
return import(/* webpackChunkName: "c" */ './module-c')
|
||||
return import(/* webpackChunkName: "c" */ "./module-c");
|
||||
}
|
||||
|
|
|
@ -1 +1 @@
|
|||
export default 'b2'
|
||||
export default "b2";
|
||||
|
|
|
@ -1,9 +1,9 @@
|
|||
import x from './module-x'
|
||||
import x from "./module-x";
|
||||
|
||||
export default function () {
|
||||
if (Math.random() < -1) {
|
||||
import(/* webpackChunkName: "a" */ './module-a')
|
||||
import(/* webpackChunkName: "b" */ './module-b')
|
||||
import(/* webpackChunkName: "a" */ "./module-a");
|
||||
import(/* webpackChunkName: "b" */ "./module-b");
|
||||
}
|
||||
return x
|
||||
return x;
|
||||
}
|
||||
|
|
|
@ -1 +1 @@
|
|||
export default 'x'
|
||||
export default "x";
|
||||
|
|
Some files were not shown because too many files have changed in this diff Show more
Loading…
Reference in a new issue