

WebpackNamely JavaScriptStatic module bundler. If used BabelIntelligent translation presupposition based on translation, BabelWill importAll translated into require, which results in browser error:īefore translation: import React from "react" Īfter translation: var React = require("react") Īfter a time-consuming search for solutions, I can only use the packaging tool to importand requireProcessing. Well, I don’t remember the specific error reporting content. Uncaught TypeError: Failed to resolve module specifier: "react"Įxport 'default' was not found in "./node_module/react/index.js" Load path / filename: import React from "./node_module/react/index.js" When I use importWhen loading path / filename, the browser will report an error Relative references must start with either "/", "./", or "./" Uncaught TypeError: Failed to resolve module specifier "react-router-dom". / plugin transform arrow functions: this plug-in will Arrow function: () = > from "react-router-dom".By installing different plug-ins, BabelDifferent functions can be realized.

Plugins, plugins, yes BabelThe main modules to achieve the function. Quote BabelOfficial website:īabelThere are several main concepts: Presets、Plugins、Config Files、Cli Babel:Plugins It needs to be converted to a lower version of JavaScript syntax to achieve compatibility. That is to say, the latest version of JavaScript syntax is not supported by some versions of browsers. So, then BabelSlightly ~īabelIt is a JavaScript compiler, which translates various versions of JavaScript language standards into the version you want. ReactRecommended on official website BabelYes jsxTranslation. babelīecause the website uses ReactBuilt up, ReactOf JSX syntaxIt’s fun to use, but jsxNeed to translate into JS official Syntax & the syntax recognized by browserTo use. On the other hand, it is hoped to save time for the friends who are lucky to see this article. On the one hand, it is convenient for the future self to check. If I didn’t write an article, I always felt that the time spent was not worth it.

Although the final solution seemed simple, the process was very hard and time-consuming. I just want to npm installGo local and use importLoad various files. One day, some CDNs collapsed, making the site useless. The main contradiction between these two questions is that I always used To load all kinds of css,js,icoEtc
#React dom 16 script tag unpkg reference code#
This article records the work related to code conversion and code packaging. When I build a website from the soil, even the most primitive one, rookie like me will encounter many trivial and small problems.
