Skip to content
Permalink
Browse files

fix: proper aot file at runtime

  • Loading branch information...
mgechev committed Jun 16, 2019
1 parent 5a9719d commit b53ba275d5a3872d90fb5f1898823c37e9671dde
@@ -8,3 +8,5 @@ tmp-*
.esm-cache/
dist
lerna-debug.log
*.d.ts

@@ -6,6 +6,9 @@ module.exports = {
filename: './guess-parser/index.js',
libraryTarget: 'umd'
},
optimization: {
minimize: false
},
externals: [/^(@|\w{3}(?<!\w:\\)).*$/i],
resolve: {
// Add `.ts` and `.tsx` as a resolvable extension.
@@ -26,7 +26,7 @@ const alterChunk = (
memoryFs.writeFileSync('/src/index.js', toAlter, 'utf-8');
memoryFs.writeFileSync(
'/src/guess-aot.js',
readFileSync(join(__dirname, 'guess.js')).toString(),
readFileSync(join(__dirname, 'guess-aot.js')).toString(),
'utf-8'
);

@@ -171,23 +171,15 @@ export class PrefetchAotPlugin {

routeChunk['/'] = mainName;

const tableOutput: any[] = [[
'Prefetcher',
'Target',
'Probability'
]];
const tableOutput: any[] = [['Prefetcher', 'Target', 'Probability']];
const generateNeighbors = (route: string, currentChunk: string, c: PrefetchAotNeighbor) => {
if (!c.chunk) {
if (this._config.debug) {
console.warn('Cannot find chunk name for', c, 'from route', route);
}
return false;
}
tableOutput.push([
currentChunk,
c.chunk,
c.probability
]);
tableOutput.push([currentChunk, c.chunk, c.probability]);
return `['${join(this._config.basePath, c.chunk)}',${c.probability}]`;
};

@@ -31,7 +31,6 @@ export interface Navigations {
[key: string]: Navigation;
}


const matchRoute = (route: string, declaration: string) => {
const routeParts = route.split('/');
const declarationParts = declaration.split('/');
@@ -106,18 +105,11 @@ export let guess: GuessFn = (params?: Partial<GuessFnParams>): Navigations => {
throw new Error('Guess is not initialized');
};

const getEffectiveType = (global: any): ConnectionEffectiveType => {
if (!global.navigator || !global.navigator || !global.navigator.connection) {
return '3g';
}
return global.navigator.connection.effectiveType || '3g';
};

export const initialize = (
global: any,
thresholds: PrefetchConfig,
compressed: CompressedPrefetchGraph,
map: CompressedGraphMap,
map: CompressedGraphMap
) => {
const graph = new Graph(compressed, map);
global.__GUESS__ = global.__GUESS__ || {};
@@ -127,7 +119,10 @@ export const initialize = (
params.path = (global.location || { pathname: '' }).pathname;
}
if (!params.connection) {
params.connection = getEffectiveType(global);
params.connection =
!global.navigator || !global.navigator || !global.navigator.connection
? '3g'
: global.navigator.connection.effectiveType || '3g';
}
if (!params.thresholds) {
params.thresholds = thresholds;
@@ -69,7 +69,7 @@ module.exports = [
Object.assign(
{
entry: {
guess: './src/aot/guess-aot.ts'
'guess-aot': './src/aot/guess-aot.ts'
},
target: 'node',
output: {
@@ -88,6 +88,9 @@ module.exports = [
path: __dirname + '/dist/guess-webpack/',
libraryTarget: 'umd'
},
optimization: {
minimize: false
},
target: 'node',
node: {
__dirname: false,

0 comments on commit b53ba27

Please sign in to comment.
You can’t perform that action at this time.