>What happens when you pass an array to entry? Passing an array of file paths to the entry property creates what is known as a "multi-main entry". This is useful when you would like to inject multiple dependent files together and graph their dependencies into one "chunk".
> learn-webworker@0.1.0 eject /Users/nishio/learn-webworker
> react-scripts eject
NOTE: Create React App 2+ supports TypeScript, Sass, CSS Modules and more without ejecting: https://reactjs.org/blog/2018/10/01/create-react-app-v2.html
? Are you sure you want to eject? This action is permanent. Yes
Ejecting...
Copying files into /Users/nishio/learn-webworker
Adding /config/env.js to the project
...
Adding /config/webpack.config.js to the project
...
Updating the dependencies
Removing react-scripts from dependencies
...
Adding webpack to dependencies
...
Updating the scripts
Replacing "react-scripts start" with "node scripts/start.js"
Replacing "react-scripts build" with "node scripts/build.js"
Replacing "react-scripts test" with "node scripts/test.js"
Configuring package.json
Adding Jest configuration
Adding Babel preset
...
Ejected successfully!
Staged ejected files for commit.
Please consider sharing why you ejected in this survey:
http://goo.gl/forms/Bi6CZjk1EqsdelXk1
$git status
:
On branch master
Changes to be committed:
(use "git reset HEAD <file>..." to unstage)
new file: config/env.js
...
new file: config/webpack.config.js
...
Changes not staged for commit:
(use "git add <file>..." to update what will be committed)
(use "git checkout -- <file>..." to discard changes in working directory)
modified: package-lock.json
modified: package.json
modified: src/react-app-env.d.ts
All files must be modules when the '--isolatedModules' flag is provided. TS1208
TSなのがいけないのか?JSにしてみる
js
// eslint-disable-next-line no-restricted-globals
addEventListener("message", message => {
console.log("Message received from main script");
console.log("in webworker", message.data);
postMessage("this is the response " + message.data * 2);
});
OK、動いた
しかし他のファイルをインポートしようとするとエラー
Uncaught SyntaxError: Cannot use import statement outside a module