UNPKG

821 BJavaScriptView Raw
1/*
2 MIT License http://www.opensource.org/licenses/mit-license.php
3 Author Yuta Hiroto @hiroppy
4*/
5
6"use strict";
7
8const Parser = require("../Parser");
9
10/** @typedef {import("../Parser").ParserState} ParserState */
11/** @typedef {import("../Parser").PreparsedAst} PreparsedAst */
12
13class AssetSourceParser extends Parser {
14 /**
15 * @param {string | Buffer | PreparsedAst} source the source to parse
16 * @param {ParserState} state the parser state
17 * @returns {ParserState} the parser state
18 */
19 parse(source, state) {
20 if (typeof source === "object" && !Buffer.isBuffer(source)) {
21 throw new Error("AssetSourceParser doesn't accept preparsed AST");
22 }
23 const { module } = state;
24 module.buildInfo.strict = true;
25 module.buildMeta.exportsType = "default";
26
27 return state;
28 }
29}
30
31module.exports = AssetSourceParser;