This repository has been archived by the owner on Jun 23, 2020. It is now read-only.
-
-
Notifications
You must be signed in to change notification settings - Fork 23
Throw SyntaxError: 'import' and 'export' may appear only with 'sourceType: module' when parse js module system used webpack #32
Comments
same here |
PR welcome |
any idea where to start? |
ok so i have found workaround module: {
rules: [{
test: /\.jsx?$/,
exclude: /node_modules/,
use: [{
loader: 'babel-loader',
options: {
babelrc: false,
presets: [
[
'env',
{
modules: false,
},
],
'stage-0',
'react',
],
plugins: [
'react-hot-loader/babel',
'transform-runtime',
'transform-async-to-generator',
'transform-decorators-legacy',
'transform-function-bind',
'transform-class-properties',
'lodash',
],
},
}],
}, {
test: /\.brfs\.js$/,
exclude: /node_modules/,
use: [{
loader: 'transform-loader?brfs',
}],
}],
}, so i just added additional loader for files with double extension |
@TrejGun your workaround doesn't work for me(( my rules section in webpack config
|
This bug occurs because to support es modules, is necessary to pass parserOpts option to brfs. Unfortunately the way to accomplish that (with local transform) is buggy I managed to workaround by saving the transform to a file and passing the relative path as option: // module-brfs.js
const brfs = require('brfs')
module.exports = function moduleBrfs(resource) {
return brfs(resource, {
parserOpts: {
sourceType: 'module'
}
})
} // webpack.config.js
{ enforce: 'post', test: /pdfkit[/\\]js[/\\]/, loader: "transform-loader?../../../module-brfs" } With this setup, the error does not occurs and brfs is ran but unfortunately it does not support when |
Sign up for free
to subscribe to this conversation on GitHub.
Already have an account?
Sign in.
This issue is for a:
Code
CLI Command
webpack.config.js
I set .babelrc
modules: false
,because i want to parse module system by webpack complier.and i both set webpack target: 'web'
Expected Behavior
no error
Actual Behavior
throw error
How could i fix this? Does
transform-loader
only support COMMONJS js file?The text was updated successfully, but these errors were encountered: