How to use the acorn-dynamic-import.default.parse function in acorn-dynamic-import

To help you get started, we’ve selected a few acorn-dynamic-import examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github fossasia / susper.com / node_modules / webpack / lib / Parser.js View on Github external
let ast;
		const comments = [];
		for(let i = 0, len = POSSIBLE_AST_OPTIONS.length; i < len; i++) {
			if(!ast) {
				try {
					comments.length = 0;
					POSSIBLE_AST_OPTIONS[i].onComment = comments;
					ast = acorn.parse(source, POSSIBLE_AST_OPTIONS[i]);
				} catch(e) {
					// ignore the error
				}
			}
		}
		if(!ast) {
			// for the error
			ast = acorn.parse(source, {
				ranges: true,
				locations: true,
				ecmaVersion: ECMA_VERSION,
				sourceType: "module",
				plugins: {
					dynamicImport: true
				},
				onComment: comments
			});
		}
		if(!ast || typeof ast !== "object")
			throw new Error("Source couldn't be parsed");
		const oldScope = this.scope;
		const oldState = this.state;
		const oldComments = this.comments;
		this.scope = {
github csxiaoyaojianxian / JavaScriptStudy / 09-Tools / 01-webpack / node_modules / webpack / lib / Parser.js View on Github external
let ast;
		const comments = [];
		for(let i = 0, len = POSSIBLE_AST_OPTIONS.length; i < len; i++) {
			if(!ast) {
				try {
					comments.length = 0;
					POSSIBLE_AST_OPTIONS[i].onComment = comments;
					ast = acorn.parse(source, POSSIBLE_AST_OPTIONS[i]);
				} catch(e) {
					// ignore the error
				}
			}
		}
		if(!ast) {
			// for the error
			ast = acorn.parse(source, {
				ranges: true,
				locations: true,
				ecmaVersion: ECMA_VERSION,
				sourceType: "module",
				plugins: {
					dynamicImport: true
				},
				onComment: comments
			});
		}
		if(!ast || typeof ast !== "object")
			throw new Error("Source couldn't be parsed");
		const oldScope = this.scope;
		const oldState = this.state;
		const oldComments = this.comments;
		this.scope = {
github abhaydoke09 / Deep-Learning-For-Surveillance / FrontEnd / node_modules / webpack / lib / Parser.js View on Github external
let ast;
		const comments = [];
		for(let i = 0, len = POSSIBLE_AST_OPTIONS.length; i < len; i++) {
			if(!ast) {
				try {
					comments.length = 0;
					POSSIBLE_AST_OPTIONS[i].onComment = comments;
					ast = acorn.parse(source, POSSIBLE_AST_OPTIONS[i]);
				} catch(e) {
					// ignore the error
				}
			}
		}
		if(!ast) {
			// for the error
			ast = acorn.parse(source, {
				ranges: true,
				locations: true,
				ecmaVersion: ECMA_VERSION,
				sourceType: "module",
				plugins: {
					dynamicImport: true
				},
				onComment: comments
			});
		}
		if(!ast || typeof ast !== "object")
			throw new Error("Source couldn't be parsed");
		const oldScope = this.scope;
		const oldState = this.state;
		const oldComments = this.comments;
		this.scope = {
github TYRMars / ES6-StepPitGuide / es6 / node_modules / webpack / lib / Parser.js View on Github external
parse(source, initialState) {
		let ast;
		const comments = [];
		for(let i = 0, len = POSSIBLE_AST_OPTIONS.length; i < len; i++) {
			if(!ast) {
				try {
					comments.length = 0;
					POSSIBLE_AST_OPTIONS[i].onComment = comments;
					ast = acorn.parse(source, POSSIBLE_AST_OPTIONS[i]);
				} catch(e) {
					// ignore the error
				}
			}
		}
		if(!ast) {
			// for the error
			ast = acorn.parse(source, {
				ranges: true,
				locations: true,
				ecmaVersion: ECMA_VERSION,
				sourceType: "module",
				plugins: {
					dynamicImport: true
				},
				onComment: comments
github xxxgitone / learningProcess / WebPack-Beginner / node_modules / webpack / lib / Parser.js View on Github external
evaluate(source) {
		const ast = acorn.parse("(" + source + ")", {
			ranges: true,
			locations: true,
			ecmaVersion: ECMA_VERSION,
			sourceType: "module",
			plugins: {
				dynamicImport: true
			}
		});
		if(!ast || typeof ast !== "object" || ast.type !== "Program")
			throw new Error("evaluate: Source couldn't be parsed");
		if(ast.body.length !== 1 || ast.body[0].type !== "ExpressionStatement")
			throw new Error("evaluate: Source is not a expression");
		return this.evaluateExpression(ast.body[0].expression);
	}
github M0nica / React-Ladies / node_modules / webpack / lib / Parser.js View on Github external
let error;
		let threw = false;
		try {
			ast = acorn.parse(code, parserOptions);
		} catch (e) {
			error = e;
			threw = true;
		}

		if (threw && type === "auto") {
			parserOptions.sourceType = "script";
			if (Array.isArray(parserOptions.onComment)) {
				parserOptions.onComment.length = 0;
			}
			try {
				ast = acorn.parse(code, parserOptions);
				threw = false;
			} catch (e) {
				threw = true;
			}
		}

		if (threw) {
			throw error;
		}

		return ast;
	}
}
github liangklfangl / commonsChunkPlugin_Config / node_modules / webpack / lib / Parser.js View on Github external
Parser.prototype.evaluate = function evaluate(source) {
	var ast = acorn.parse("(" + source + ")", {
		ranges: true,
		locations: true,
		ecmaVersion: 2017,
		sourceType: "module",
		plugins: {
			dynamicImport: true
		}
	});
	if(!ast || typeof ast !== "object" || ast.type !== "Program")
		throw new Error("evaluate: Source couldn't be parsed");
	if(ast.body.length !== 1 || ast.body[0].type !== "ExpressionStatement")
		throw new Error("evaluate: Source is not a expression");
	return this.evaluateExpression(ast.body[0].expression);
};
github enigmampc / secret-contracts / node_modules / webpack / lib / Parser.js View on Github external
evaluate(source) {
		const ast = acorn.parse("(" + source + ")", {
			ranges: true,
			locations: true,
			ecmaVersion: ECMA_VERSION,
			sourceType: "module",
			plugins: {
				dynamicImport: true
			}
		});
		if(!ast || typeof ast !== "object" || ast.type !== "Program")
			throw new Error("evaluate: Source couldn't be parsed");
		if(ast.body.length !== 1 || ast.body[0].type !== "ExpressionStatement")
			throw new Error("evaluate: Source is not a expression");
		return this.evaluateExpression(ast.body[0].expression);
	}
github TYRMars / ES6-StepPitGuide / es6 / node_modules / webpack / lib / Parser.js View on Github external
evaluate(source) {
		const ast = acorn.parse("(" + source + ")", {
			ranges: true,
			locations: true,
			ecmaVersion: ECMA_VERSION,
			sourceType: "module",
			plugins: {
				dynamicImport: true
			}
		});
		if(!ast || typeof ast !== "object" || ast.type !== "Program")
			throw new Error("evaluate: Source couldn't be parsed");
		if(ast.body.length !== 1 || ast.body[0].type !== "ExpressionStatement")
			throw new Error("evaluate: Source is not a expression");
		return this.evaluateExpression(ast.body[0].expression);
	}
github miukimiu / react-kawaii / node_modules / webpack / lib / Parser.js View on Github external
Parser.prototype.evaluate = function evaluate(source) {
	var ast = acorn.parse("(" + source + ")", {
		ranges: true,
		locations: true,
		ecmaVersion: 2017,
		sourceType: "module",
		plugins: {
			dynamicImport: true
		}
	});
	if(!ast || typeof ast !== "object" || ast.type !== "Program")
		throw new Error("evaluate: Source couldn't be parsed");
	if(ast.body.length !== 1 || ast.body[0].type !== "ExpressionStatement")
		throw new Error("evaluate: Source is not a expression");
	return this.evaluateExpression(ast.body[0].expression);
};