|
| 1 | +import { foo as cjsexport_harmonyimport } from "./cjs-module"; |
| 2 | +import theDefault, { bar as harmonyexport_harmonyimport } from "./harmony-module"; |
| 3 | +import theDefaultExpression from "./export-default-expression"; |
| 4 | +const { harmonyexport_cjsimport } = require("./harmony-module").bar; |
| 5 | +const harmonyexport_cjsimportdefault = require("./export-default-expression").default; |
| 6 | +import { baz as harmonyexport_harmonyimport_2 } from "./harmony-module-2"; |
| 7 | + |
| 8 | +import * as mod3 from "./harmony-module-3"; |
| 9 | +export { mod3 }; |
| 10 | +export { theDefaultExpression } |
| 11 | + |
| 12 | +const { expectSourceToContain, expectSourceToMatch } = require("../../../helpers/expectSource"); |
| 13 | +const regexEscape = require("../../../helpers/regexEscape.js"); |
| 14 | + |
| 15 | +// It's important to use propertyName when generating object members to ensure that the exported property name |
| 16 | +// uses the same accessor syntax (quotes vs. dot notatation) as the imported property name on the other end |
| 17 | +// (which needs to use propertyAccess). Else, minifiers such as Closure Compiler will not be able to minify correctly. |
| 18 | +it("should use the same accessor syntax for import and export", function() { |
| 19 | + |
| 20 | + var fs = require("fs"); |
| 21 | + var source = fs.readFileSync(__filename, "utf-8").toString(); |
| 22 | + |
| 23 | + // Reference these imports to generate uses in the source. |
| 24 | + |
| 25 | + cjsexport_harmonyimport; |
| 26 | + harmonyexport_harmonyimport; |
| 27 | + harmonyexport_cjsimport; |
| 28 | + harmonyexport_harmonyimport_2; |
| 29 | + theDefault; |
| 30 | + theDefaultExpression; |
| 31 | + harmonyexport_cjsimportdefault; |
| 32 | + |
| 33 | + /*********** DO NOT MATCH BELOW THIS LINE ***********/ |
| 34 | + |
| 35 | + // Checking harmonyexportinitfragment.js formation of standard export fragment |
| 36 | + expectSourceToContain(source, "/* harmony export */ bar: () => (/* binding */ bar)"); |
| 37 | + |
| 38 | + // Checking formation of imports |
| 39 | + expectSourceToMatch(source, `${regexEscape("const { harmonyexport_cjsimport } = (__webpack_require__(/*! ./harmony-module */ ")}\\d+${regexEscape(").bar);")}`); |
| 40 | + expectSourceToMatch(source, `${regexEscape("const harmonyexport_cjsimportdefault = (__webpack_require__(/*! ./export-default-expression */ ")}\\d+${regexEscape(")[\"default\"]);")}`); |
| 41 | + |
| 42 | + // Checking concatenatedmodule.js formation of exports |
| 43 | + expectSourceToContain(source, "mod3: () => (/* reexport */ harmony_module_3_namespaceObject)"); |
| 44 | + |
| 45 | + // Checking concatenatedmodule.js formation of namespace objects |
| 46 | + expectSourceToContain(source, "apple: () => (apple)"); |
| 47 | + |
| 48 | + // Do not break default option |
| 49 | + expectSourceToContain(source, "[\"default\"] = (___CSS_LOADER_EXPORT___)"); |
| 50 | +}); |
0 commit comments